Chapter: Using jelix scripts
|« Server configuration||^ Getting started|
− Table of content
Jelix provides some few CLI scripts:
bin/create-jelix-app, allowing you to create a new application,
dev.phpinside 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
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
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
In other distribution, they can be
Note that for Debian and Ubuntu, extensions configurations are shared between
apache and cli, in a
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.
- open the file
.profilestored into your home directory (
- 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/binReplace in this example
$VERSIONPHPbye the version of PHP. The line should look like to this:
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
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:
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,
Then, type this kind of command line:
php.exe dev.php <command_name> [options] [parameters]
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
php dev.php help
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.
lib/jelix-scripts/templates/, there is a file
You can copy it in two places, by renaming it to
- 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=2019 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>
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.