Quick links: Content - sections - sub sections
EN FR

Jelix provides some CLI script, lib/jelix-scripts/createapp.php, allowing you to create a new application, and cmd.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 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.3.13\. 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 cmd.php

This script, stored in your application, must be invoked with the command line version of PHP. So, 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 cmd.php  command_name [options] [parameters]

With linux:


$ php cmd.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 cmd.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 cmd.php help

The option -ep

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 option "-ep":


  php cmd.php installmodule -ep admin.php foo

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

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

l'option -v

This is an option available for all commands since Jelix 1.3.3. It allows you to display all details about what the command did after 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]
incofCopyright=2012 my company

List of available commands

here is a list of some commands

  • Main commands

php cmd.php COMMAND [-v] [-ep ENTRYPOINT] [OPTIONS] [PARAMETERS]
  • Creation of one module

php cmd.php createmodule [MyModule]
  • Creation of one dao

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

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

php cmd.php createform [MyModule] [MyForm] [MyDao] 
  • Creation of a zone (with or without a template)

php cmd.php  createzone [-notpl] [MyModule] [MyZone] [MyTemplate] 
  • Creation of one CRUD, create dao, form and CRUD controller

php cmd.php createdaocrud module table controller_name