Lesson 9.1: The console
Exponential has more than a hundred command line scripts. The console, php bin/php/console, finds all of them,
those of the kernel and those of every extension, describes them and runs them by name. In this lesson learners find
their way through it, so that the next lesson's command of their own appears in the list beside the kernel's.
At a glance
| Course | Developers |
| Module | Module 9: The console and persistent objects |
| Duration | 35 minutes (10 presenting, 25 exercise) |
| Level | Beginner |
| Audience | Developers and administrators |
| Prerequisites | Module 1 |
Learning objectives
After this lesson, learners can:
- list every command, or the commands of one namespace, with
php bin/php/console list; - read a command's help in three ways;
- explain the namespaces
exp:,shell:,bin:,ext:<ext>:andcron:; - run a cronjob part with
cron:<part>and show the crontab withcrontab:list; - explain
--allow-root-userand why commands should run as the site user.
Trainer's notes
How to present it
Source: Exponential Console.
list(3 minutes).php bin/php/console listprints every command with a one-line description, grouped by namespace;list exp,list shell,list cron,list ext:<ext>filter.Names (3 minutes). Project the table:
Namespace Runs exp:<name>bin/php/<name>.phpshell:<name>bin/shell/<name>.shbin:<name>bin/<name>.shorbin/<name>.phpext:<ext>:<name>extension/<ext>/bin/php/<name>.phporextension/<ext>/bin/<name>.shcron:<part>a cronjob part through runcronjobs.phpWithout a namespace the console tries
exp:, thenshell:, thenbin:. Many commands have aliases, such asexp:logsforexp:explogs.Help (2 minutes).
help <command>,--help <command>and<command> --helpprint the script's own usage.Root (2 minutes). Scripts refuse to run as root without
--allow-root-user; files a script writes as root can break a site that runs as another user.
Common questions
Is ./console the same? Yes, if you made the link ln -s bin/php/console console; it is not shipped.
Where do descriptions come from? From a @description tag in the script's docblock (lesson 9.2).
Can I see scheduled jobs? php bin/php/console crontab:list prints the system crontab of the current user;
Setup > Cronjobs shows the parts in the browser.
Pitfalls
- Running from another directory. The console must run from the installation root, or
autoload.phpis not found. - Commands that delete. Some commands remove data (
exp:trashpurge,exp:cleanupversions). Read--helpfirst and prefer--dry-runwhere offered. - Typos. An unknown name prints "Did you mean:" with the closest match.
Hands-on exercise
On the development installation, from its root folder.
- List every command and count them:
php bin/php/console list | tail -3. - List the cronjob parts:
php bin/php/console list cron. - List the shell commands:
php bin/php/console list shell. - Read the help of the cache command in two ways:
php bin/php/console help exp:ezcacheandphp bin/php/console exp:ezcache --help. - Mistype a name on purpose:
php bin/php/console exp:ezcach. Read the suggestion. - Find the command that checks template syntax and the one that compiles templates (hint:
list exp, look fortemplate). - Run the system information command and read its first lines:
php bin/php/console exp:systeminfo | head -20. - Show the version:
php bin/php/console --version.
Expected result
- Step 1 ends with the number of commands available.
- Step 2 lists parts such as
cron:frequentandcron:infrequentwith descriptions. - Step 5 prints
UNKNOWN COMMAND,Command "exp:ezcach" was not found.andDid you mean: exp:ezcache. - Step 6:
exp:eztemplatecheckandexp:eztc. - The trainer asks each learner which file
ext:mysite_hello:latestwould run.
Quiz
- Which command lists the commands of one extension?
- What does
exp:ezcacherun? A.bin/shell/ezcache.shB.bin/php/ezcache.phpC.cronjobs/ezcache.phpD.kernel/ezcache.php - Name two ways to read a command's help.
- Why does a script refuse to run as root?
- Which file does
ext:mysite_hello:latestrun?
Answers
php bin/php/console list ext:<ext>.- B.
bin/php/ezcache.php. - Two of
help <command>,--help <command>,<command> --help. - Files written as root can break a site that runs as another user;
--allow-root-userconfirms on purpose. extension/mysite_hello/bin/php/latest.php.
Further reading
- Exponential Console: names, options, cronjob parts and extension commands.
- The cronjobs console: the browser view of the cronjob parts.
Related pages
- Module 9: The console and persistent objects
- Developers: 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.