Lesson 5.3: Packages on the command line with ezpm
ezpm.php is the package manager on the command line. It does what the packages pages do, and more: it packages a
whole content subtree, exports in the JSON format and installs large packages without a browser that might time out.
In this lesson learners package the content of Site B and look at the result without installing it anywhere.
At a glance
| Course | Multisite and site packages |
| Module | Module 5: Site packages |
| Duration | 55 minutes (20 presenting, 35 exercise) |
| Level | Advanced |
| Audience | Administrators and developers |
| Prerequisites | Lesson 5.2; Site B with some content (modules 1 and 2) |
Learning objectives
After this lesson, learners can:
- run
ezpm.phpdirectly and through the console, and read its help per command; - create a package and add a content subtree with chosen options;
- export a package as
.ezpkgin the classic or the JSON format, and validate an archive; - explain the lock, the batched commits and the delayed indexing of
install; - name the steps after a large install (search index, caches).
Trainer's notes
How to present it
Source: ezpm: the package manager on the command line.
Running it (3 minutes).
php ezpm.php helplists the commands:create,install,import,export,convert,validate,check,add,set,delete,list,info.php ezpm.php help <command>explains one.php bin/php/console list ezpmshows the console's entry. Global options include-s(siteaccess),-r(repository),-q(quiet) and-l/-p(log in as a user).A content subtree package (6 minutes). Three steps:
create,add,export.php ezpm.php create mypackage 'My package summary' 1.0.1 install php ezpm.php add mypackage ezcontentsubtree /content/my-page --exclude-classes --siteaccess=site php ezpm.php export mypackage -d var/tmpezcontentsubtreeis an alias ofezcontentobject; it takes a node ID or a URL path. Options include--include-classes/--exclude-classes,--include-templates/--exclude-templates,--language=,--current-version/--all-versionsand--minimal-template-set.Formats and checks (3 minutes).
export --format=jsonwrites the JSON format with checksums;validate <archive, directory or name>checks a package in either format without importing it.Installing (6 minutes).
install <name> [-d <node id>]puts content objects under a parent node (default 2). One run at a time:installandaddtake a lock (ezpm.lockin the var directory). View and template caches are off and search indexing is delayed for the run; the content handler commits every 50 objects; dependencies are installed first.--as-draftswrites content objects as drafts and installs nothing else. Afterwards:php bin/php/updatesearchindex.phpand a cache clear.
Common questions
Do I need --allow-root-user? The check that wrote the feature page found that ezpm.php ran as root without
it, while other scripts ask for it. Run as the site user and the question does not arise.
Can I install the package on the same installation? You can, but it writes content. In this course we export and validate only; installing is lesson 5.6, on a copy.
What does "Another ezpm process is currently running" mean? A second install or add started while the first
holds the lock. Wait for the first.
Where do exports go without -d? Into the current directory.
Pitfalls
- Exporting into the web root. An
.ezpkgin a public directory can be downloaded by anyone who guesses its name. Usevar/tmpor a directory outside the document root, and remove it after the course. - Classes in content packages. Without
--exclude-classesthe package carries the content classes; installing it elsewhere then meets existing classes. Decide on purpose. - Templates. By default the template overrides go with the content; use
--exclude-templateswhen only content should move.
Hands-on exercise
Use your training installation. Commands run in its root directory as the site user.
Read the help:
php ezpm.php help, thenphp ezpm.php help addandphp ezpm.php help export.List the packages:
php ezpm.php list.Create a package for the content of Site B:
php ezpm.php create clubb_content 'Content of Site B' 1.0.0 installAdd the folder Site B and everything below it, without classes and templates (replace
NNNwith its node ID):php ezpm.php add clubb_content ezcontentsubtree NNN --exclude-classes --exclude-templatesWatch the status line name its phases.
Show the package:
php ezpm.php info clubb_content.Export it in both formats:
mkdir -p var/tmp/course php ezpm.php export clubb_content -d var/tmp/course php ezpm.php export clubb_content -d var/tmp/course --format=json ls -l var/tmp/courseValidate both archives:
php ezpm.php validate var/tmp/course/<file>.ezpkgfor each.Open Setup > Packages in the administration and find
clubb_contentin thelocalrepository; open its page and look at What it carries and Package contents.Read the
installhelp (php ezpm.php help install) and write down what-dand--as-draftswould do.At the end of the course, remove
var/tmp/course(your trainer will say when).
Expected result
- Step 4 ends without error and the status line showed phases such as Collecting subtree nodes and Serializing content objects.
- Step 6 lists two archives:
clubb_content-<version>...ezpkgand a.json.ezpkg. - Step 7 reports both valid.
- Step 8: the package is in
local, with the folder Site B and its sub items as content, no classes. - The trainer checks step 7 on one lab.
Quiz
- Which three
ezpmcommands build a content subtree package and write it to a file? - What does
--exclude-classeschange? A. The content is left out B. The content classes are left out C. Templates are left out D. Nothing - Why do
installandaddtake a lock? - What must you run after a large
install, and why? - Which command checks an archive without importing it?
Answers
create,add(withezcontentobjectorezcontentsubtree) andexport.- B.
- So that only one run works at a time; two parallel runs caused database lock wait timeouts (ezpm).
php bin/php/updatesearchindex.phpand a cache clear, because indexing was delayed and caches were off for the run.php ezpm.php validate <archive>.
Further reading
- ezpm: the package manager on the command line.
- The JSON package format.
- Exporting with ezpm.
- Packages, 11. From a shell.
Related pages
- Module 5: Site packages
- Multisite and site packages: course overview
- Trainers: start here
- Free documentation: this page is free to copy, translate and improve under the GNU FDL 1.3.
Become an Exponential Partner
Partners share their information, provide funding, contribute back and develop the products with us, and that is how Exponential grows. A partner website and dashboard are planned for mid-2027: please become a partner today to speed up our growth rate and land new features faster.