Skip to the content
Documentation
Help Start
Reading in:
  • German: 9,059 of 9,059 pages
About the help in other languages
All help pages

Command line: the console and eZScript

The Exponential counterpart of bin/console, artisan, manage.py, rails commands and Spring Boot runners - bin/php/console with its exp:, ext:, shell: and cron: namespaces, writing a command as an…

Download as PDF

Address: https://doc.exponential.earth/learninminutes/exphelp/viewer/help/web-framework-developers/cli-and-console-commands.md

On this page

Command line: the console and eZScript

This page is for developers who live in bin/console, php artisan, manage.py or bin/rails. Exponential has one entry point for every command, bin/php/console (installations usually add a ./console shortcut in the root). It finds commands at run time from their file location, so an extension's command needs no registration (Exponential Console, Console commands).

Contents

  1. Finding commands
  2. Command names
  3. Writing a command
  4. Siteaccess, user and root
  5. Commands you will use daily
  6. Compared with other frameworks

Finding commands

php bin/php/console                   # every command
php bin/php/console list ext:expdemo  # one namespace
php bin/php/console --version

Command names

NamespaceRunsExample
exp:<name>bin/php/<name>.phpexp:ezcache
shell:<name>bin/shell/<name>.sh
bin:<name>bin/<name>.sh or .php
ext:<ext>:<name>extension/<ext>/bin/php/<name>.php or bin/<name>.shext:expqueue:status
cron:<part>a cronjob partcron:frequent

A script can declare extra names with an @alias tag in its docblock (bin/php/exphelp.php declares @alias exp:help), and a @description tag describes it in list.

Writing a command

New commands are classes extending Exponential\Runnable\Command, called by a one-line script (CLI scripts with eZScript):

<?php
// extension/expdemo/classes/runnable/commands/report.php
namespace Exponential\Command\Extension\Expdemo;

class Report extends \Exponential\Runnable\Command
{
    public function run()
    {
        $this->script( array( 'description' => "Writes the monthly report",
                              'use-session' => false, 'use-modules' => true, 'use-extensions' => true ) );
        $options = $this->startup( '[month:][dry-run]', '', array(
            'month'   => 'The month, YYYY-MM',
            'dry-run' => 'Show what would be written, write nothing' ) );
        $this->output( \expDemoReportService::build( $options['month'], !empty( $options['dry-run'] ) ) );
        $this->shutdown( 0 );
    }
}
#!/usr/bin/env php
<?php
// extension/expdemo/bin/php/report.php
require_once 'autoload.php';
\Exponential\Command\Extension\Expdemo\Report::main( __FILE__ );

Run it: php bin/php/console ext:expdemo:report --month=2026-10 --dry-run. The classic form, used by many scripts, calls eZScript::instance(), startup(), getOptions(), initialize() and shutdown() directly; output goes through eZCLI (output(), notice(), warning(), error()). Option strings use [name:] for a value and [name] for a flag; --help, -s/--siteaccess, --allow-root-user and the debug options are added for you.

Siteaccess, user and root

  • -s <siteaccess> selects the settings; extensions active only in that siteaccess need it.
  • The user is anonymous. A command that writes content signs in a dedicated user (eZUser::setCurrentlyLoggedInUser( $user, $user->id() )), never the shared administrator.
  • Scripts refuse to run as root unless --allow-root-user is given; run them as the web server's user, because files a root process writes into var/ break the site later.
  • The exit code is returned unchanged: shutdown( 0 ) for success, anything else for failure.
  • Offer --dry-run for every command that writes or deletes, and never accept passwords as options.

Commands you will use daily

CommandDoes
exp:ezpgenerateautoloads -eregenerate extension autoloads after adding classes
exp:ezcache --clear-tag=iniclear caches by tag or id
exp:cache statusevery cache layer, PASS or FAIL
exp:ini get/set/whereread and change settings
exp:velocity deployautoloads, caches, PHP reload, Velocity restart, in order
exp:installa new installation in one command (Installing in one command)
exp:help check, exp:help searchthe help's link check and search
exp:maintenance on/offmaintenance mode
cron:<part>run a cronjob part

Compared with other frameworks

FrameworkConceptExponential
Symfonycommands registered as services, #[AsCommand]files found by location, Exponential\Runnable\Command
LaravelArtisan commands, $signaturethe option string of startup() / getOptions()
Djangomanagement commands in management/commands/scripts in extension/<ext>/bin/php/
Railsrake tasks, bin/rails commandsthe same
SpringCommandLineRunnera command class

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.

Something wrong on this page? Report an error

Documentation license

This documentation is free documentation, licensed under the GNU Free Documentation License 1.3 or later.

Exponential Copyright © 1998-2026 Exponential Foundation and 7x