eep-bundle: eep is back, this time for eZ Platform / Ibexa DXP
By: Benjamin Kroll | December 1, 2022 | eep, eep-bundle, tools, command line, ibexadxp, and ez platform
We’ve discussed eep (Ease eZ Publish) several times over the years. It’s a powerful tool we at Mugo Web have used for innovative solutions. For the uninitiated, eep is a collection of scripts to support developers working with eZ Publish. Now that eZ Publish is a legacy product, we needed a new option for eZ Platform and Ibexa DXP. Introducing eep-bundle, a collection of Symfony commands specifically selected to work with the new system! We’ll dive in and look at some of the more useful functions eep-bundle provides, such as commands to work with cache, content, content field and type, location, section, and user data.
Why would I want to use eep-bundle?
eep-bundle is useful for many reasons. It allows a developer to quickly review a site’s structure and content, by command line, without having to log into the admin interface. It can help report or extract information directly from the CMS. For instance, if you wanted to know how many blog posts were on the site, what their location IDs were, or what the publication dates are, eep can quickly pull that information for you. It can be used to create, manipulate, or delete data directly from the command line.
Other commercial CMSes have command line tools to accompany their development tools, and we felt Ibexa deserved one too. eep-bundle expands the functionality of the platform for developers. It helps put power in the programmer’s hands, at their level.
Where can I get eep-bundle?
You can download the eep-bundle package at https://packagist.org/packages/mugoweb/eep-bundle or https://github.com/mugoweb/eep-bundle. Supported versions include eZ Platform 2.5LTS, Ibexa DXP 3.3LTS, and 4.6LTS. The features should be the same between all versions unless related to functionality that has been removed from the CMS based on version.
How do I use eep-bundle?
Listing commands
php bin/console list eep (all) php bin/console list eep:content (only the content group commands)
Built-in help for parameters, shortcuts, and usage on any command via -h
php bin/console eep:content:create -h
Non-interactive mode on commands that have interactive prompts via -n
php bin/console eep:location:copy -n <source-location-id> <target-location-id>
Pagination on commands with long listings via --limit and --offset
php bin/console eep:location:subtree 43
A command line view showing the location:subtree command for location 43 (the media library) without limit or offset options set.
The command output shows a data table listing all (5) media library subtree objects.
php bin/console eep:location:subtree 43 --limit=2
A command line view showing the location:subtree command for location 43 (the media library) with the limit option set to two.
The command output shows a data table listing only the first two media library subtree objects.
Results table columns
Unless indicated, the column names map directly to the object properties or field identifiers they represent.
Some columns are composites or show modified content. Those columns are noted in the table's legend and marked in the column's header.
The command output shows a data table with a legend indicating that column content marked as m is modified output.
Two of the rows have columns marked like this, showing truncated content (first and last 40 characters).
Header vs. data rows
The data tables presenting the output of many eep commands are separated into header and data rows by using a unique column separator for each type of row.
Header rows use I (uppercase i), while data rows use | (pipe).
This is one of the key concepts in eep, which allows results tables to be easily processed further by other command line programs.
Thanks to this feature, building pipelines with eep can replace entire scripts.
An example
List the first 6 folder content objects, use awk to extract the content id from the data rows, and store it in a file.
php bin/console eep:contenttype:listcontent folder --limit=6 | awk '$1=="|" {print $2}' > my_content_ids.txt
Pass each of the content ids to xargs to another eep command to list the content's fields.
cat my_content_ids.txt | xargs -ICONTENTID php bin/console eep:content:listfields CONTENTID
A command line view showing the data table output of the contenttype:listcontent command for folder objects.
The first command is extended by piping the output to awk, which displays only the data of the contentId column.
The command is extended again by piping the content id output to a file.
In a new command, the contents of the file are piped to xargs using cat. xargs then calls the content:listfields command for each of the content ids it receives.
The final output is a sequence of data tables listing field information for each folder content object.
Alternative argument formats
Some commands can receive argument input from a file rather than as a string from the command line.
This helps to avoid "escaping hell" when trying to supply complex input as a string.
Creating content by supplying the data argument JSON string directly
eep:content:create folder 43 '{ "name": "Foobar" }' eng-GB
Creating content by supplying the data argument JSON from a file
eep:content:create --from-file folder 43 './foobar.json' eng-GB
Command user
By default, eep runs commands as the CMS's default administrator user (user id: 14)
This allows for all operations to be performed without restrictions but may not be desired for all use cases.
Every eep command supports the --user-id option, which allows the user the command is executed as to be changed.
php bin/console eep:location:subtree 43 --user-id=10
Note: this command would fail, as the default anonymous user (id=10) does not have content/read permissions for the media library (id=43)
Symfony’s command framework
A lot of the heavy lifting around input, output, and argument handling in eep-bundle is done by the console component and related utilities. It provides many helpful tools and handles a lot of expected functionality out of the box.
Combined with eZ/Ibexa’s APIs, each command is fairly short and should be easy to follow. It aims to do one thing and do it well.
Mugo is made up of experts ready to help
eep-bundle is a powerful and specific tool developed by Mugo. It’s just an example of the type of critical thinking and skills our developers can bring to the table, and we’re happy to share eep with the community. We’re also happy to help with your Ibexa project. Contact us today for expert answers to all your questions.