Quick links: Content - sections - sub sections
EN FR

Jelix provides some few CLI scripts:

  1. bin/create-jelix-app, allowing you to create a new application,
  2. and dev.php inside your application allowing to execute commands on your application. Particularly, you are able to create and modify some files easily and automatically.

This scripts 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 or php7.x-cli (where x is the minor version of PHP) package to be able 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 PHP-FPM or 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. For example, in Debian Jessie, these two files are /etc/php5/apache2/php.ini and /etc/php5/cli/php.ini. In other distribution, they can be /etc/php/php7.0/apache2/php.ini and /etc/php/php7.0/cli/php.ini.

Note that for Debian and Ubuntu, 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/php$VERSIONPHP/bin Replace in this example $VERSIONPHP bye the version of PHP. The line should look like to this:

export PATH=/Applications/MAMP/Library/bin:/Applications/MAMP/bin/php5.6/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. For example, add c:\wamp\bin\php\php5.6.5\. Don't forget to add a ";" to separate all paths.
  • validate and close the dialog
  • reboot

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

On a shared hosting server

To use jelix-scripts on a shared hosting, your hosting provider should allow you to access the server with a SSH access.

Then you have to check two things:

  • check the PHP version you have in the command line: php --version. You may have to setup the right version into the manager provided by your provider.
  • sometimes, some superglobals variables are not set correctly. $_SERVER['SCRIPT_NAME'] may be missing. You then have to set some variables from the command line: export SCRIPT_NAME=dev.php.

Read the documentation of your hosting provider.

Using dev.php

Open a console (cmd.exe under windows), and go to the directory of your application, myapp/:

With Linux/Mac:


cd myapp/

With Windows:


cd myapp\

Then, type this kind of command line:

With Windows:


php.exe dev.php <command_name> [options] [parameters]

With linux:


php dev.php <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 dev.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 dev.php help

Use the list command to see the list of all available commands.


   php dev.php list

option -v

This is an option available for all commands. It allows you to display all details about what the command did during its execution.

By default, a command displays nothing except errors. If you want to display details each time you launch a command, you can modify the configuration of jelix-scripts with the parameter verboseMode=true. See below.

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 these informations.

In lib/jelix-scripts/templates/, there is a file jelix-scripts.ini. You can copy it in two places, by renaming it to .jelix-scripts.ini.

  • into one of the parent directory of the application
  • into your home directory (/home/yourlogin/ for example in Linux or c:\Users\yourlogin\ with windows 7)

Jelix-scripts searches a .jelix-scripts.ini in the current directory and its parent directories, before searching in the home directory.

You can then modify it by changing different values. If you want different values for each application, create section in the file, named with the name of the application, and set values in it.


[myapp]
infoCopyright=2020 my company

List of available commands

here is a list of some commands

  • Main commands

php dev.php COMMAND [-v] [OPTIONS] [PARAMETERS]
  • Creation of one module

php dev.php module:create <MyModule>
  • Creation of one dao

php dev.php module:create-dao <MyModule> <MyDao> <MyTable>
  • Creation of one class based upon a dao

php dev.php module:create-class-dao <MyModule> <MyClass> <MyDao>
  • Creation of one form (empty of from a dao, with or without locales)

php dev.php module:create-form <MyModule> <MyForm> <MyDao>
  • Creation of a zone (with or without a template)

php dev.php module:create-zone [--notpl] <MyModule> <MyZone> <MyTemplate>
  • Creation of one CRUD, create dao, form and CRUD controller

php dev.php module:create-dao-crud <module> <table> <controller_name>

Type php dev.php list to have the full list. Some other chapter of the manual will talk about some commands and how to use it.