Quick links: Content - sections - sub sections
EN FR

Jelix provides a CLI script, lib/jelix-scripts/jelix.php. It allows you to execute commands in your application context. Particularly, you are able to create and modify some files easily and automatically.

This script should be called from a console, in a command line, so the command line version of PHP (PHP-CLI) should be installed and configured.

Configuration of PHP-CLI

On Debian/Ubuntu/other linux distro

You should install the php5-cli package to execute a PHP script on a command line.

Careful, in most distro, particularly in Debian/Ubuntu, the configuration file of PHP, php.ini, is not the same for Apache, and for the command line version of PHP. So don't forget to configure same important parameters in these two php.ini, and to activate same php extensions. Under Debian/Ubuntu, these two files are /etc/php5/apache2/php.ini and /etc/php5/cli/php.ini. Note that for this distro, extensions configurations are shared between apache and cli, in a conf.d directory.

With MAMP (MacOS X)

The MAMP software provides PHP-Cli. Perhaps there is also an other PHP-CLI already installed un MacOS. And then, the problem is that PHP-CLI for MAMP is not configured to access to the MAMP mysql.

The solution:

  • open the file .profile stored into your home directory (/Users/your_login/)
  • Modify the line where the PATH variable is defined, or add it. The goal is to add some path in this variable (/Applications/MAMP/Library/bin:/Applications/MAMP/bin/php5.3/bin). The line should look like to this:

export PATH=/Applications/MAMP/Library/bin:/Applications/MAMP/bin/php5.3/bin:$PATH

If it was already exist, some other paths were probably defined, keep them. In all case, the $PATH should be at the end.

Configuration of PHP-Cli under windows

Depending of the package you use (WAMP or others), your php.exe may not found its php.ini file. The CLI version of php and the apache version of PHP do not share the same php.ini file. So you should create it for php.exe and/or configure it to activate same extensions as the apache php. Else you could have some errors like "unknow mysql_connect function" or "unable to connect to localhost" etc.

You have also to add the path to the php-cli binary in the PATH variable of your system.

  • right click on the icon of computer, then choose properties
  • In the system properties dialog, click on the tab "advanced", then on the button to see the environment variables.
  • In "system variable", click on the PATH variable
  • Change the value of the PATH variable, by adding the path to the directory of the binary of php.exe. With WAMP for example, add c:\wamp\bin\php\php5.2.6\. Don't forget to add a ";" to separate all pathes.
  • validate and close the dialog
  • reboot

Then you can call php.exe from any directory, and from the jelix-scripts directory.

Using jelix.php

This script must be invoked with the command line version of PHP. So, open a console (cmd.exe under windows) and go to the lib/jelix-scripts/ directory:

With Linux/Mac:


   cd lib/jelix-scripts/

With Windows:


   cd lib\jelix-scripts\

Then, type this kind of command line:

With Windows:


> php.exe jelix.php [--application_name] command_name [options] [parameters]

With linux:


$ php jelix.php [--application_name] command_name [options] [parameters]

In next examples, we only show for linux, but parameters will be identical for windows.

command_name

You should always call jelix.php with a "jelix command" name, and optionally some options and/or parameters.

First, you access help on all available commands with the help command:


   php jelix.php help

--application_name

Another generic parameter you have to indicate for most of jelix commands : your application name. This is always the first parameter of jelix.php, and it must be preceded by --. Example


  php jelix.php --myapp createapp

The application name is the name of the directory of your application, and jelix.php expect to find it at the same level of the lib directory. You can of course change this behavior. See below.

Alternatively, you can avoid typing your application name by setting an environment variable: JELIX_APP_NAME. For example, type this in the console:


  export JELIX_APP_NAME="myapp"        # under linux
  set JELIX_APP_NAME=myapp             # under windows

Then you can type any command without --myapp


  php jelix.php createapp

Notice that you can execute the script from any directory. For example, you can type:


  php jelix/path/lib/jelix-scripts/jelix.php --myapp createapp

--application_name:entrypoint

For some commands, it is useful to indicate for which entrypoint the command should be applied. To do it, you have to indicate the name of the entrypoint after the application name followed by a ":":


  php jelix.php --myapp:admin installmodule foo

It will install the foo module, only for the entry point "admin" of the application myapp. (you can write admin or admin.php)

The entry point should be declared in the project.xml file of the application.

Changing the default configuration

Commands creating new files or directories follow a specific tree structure. Perhaps you may want to organize your files in a different manner. Also, there are some customizable infos stored in header comments of files, like your name, the project name and so on.

You can configure all of this by creating a configuration file for jelix.php CLI script.

In lib/jelix-scripts/, there is a file my.default.conf.php.dist. Rename it to my.default.conf.php, and modify its settings by changing the different values. If you want different file for each application, replace "default" by the name of the application, for example: my.testapp.conf.php.

You can also create another file, in any other directory, (to have different configuration for each projects for example). If you do so, just indicate its path in JELIX_CONFIG environment variable.

List of available commands

here is a list of the main commands for jelix-scripts

  • Main commands

php jelix.php [--APPNAME[:ENTRYPOINT]] COMMAND [OPTIONS] [PARAMETERS]
  • Creation of one application

php jelix.php --[MyApplication] createapp
  • Creation of one module

php jelix.php --[MyApplication] createmodule [MyModule]
  • Creation of one dao

php jelix.php --[MyApplication] createdao [MyModule] [MyDao] [MyTable]
  • Creation of one class based upon a dao

php jelix.php --[MyApplication] createclassfromdao [MyModule] [MyClass] [MyDao]
  • Creation of one form (empty of from a dao, with or without locales)

php jelix.php --[MyApplication] createform [MyModule] [MyForm] [MyDao]