Back to the module list

Command line interface

Drive all the controllers of the application from CLI The application must be hide in a directory (by example ./bin). Don't forget to limit access to this directory by an .htaccess file containing deny from all

#!/usr/bin/php5
<?php
require ("domframework/cli.php");
$cli = new Domframework\Cli;
$cli->run();
');

The CLI file must be executable by chmod 755 cli.php. The available commands are :

Execute in CLI a controller or a model (in expert mode)
  ./cli.php -h : display this help
  ./cli.php -list : display controllers
  ./cli.php -expert -list : display controllers and models
  ./cli.php -listmethods &lt;class&gt; :
     display the methods available in the controller class
  ./cli.php -expert -listmethods &lt;class&gt; :
     display the methods available in the model or controller class
  ./cli.php -listmethodsdetails &lt;class&gt; :
     display the methods available in the controller class
  ./cli.php -expert -listmethodsdetails &lt;class&gt; :
     display the methods available in the model or controller class
  ./cli.php &lt;class&gt; &lt;method&gt; [args]
     execute the method with the provided args
  ./cli.php -expert &lt;class&gt; &lt;method&gt; [args]
     execute the method with the provided args
You can replace ONE arg by a dash (-) to read from stdin
Arrays must be coded like key1=val1&amp;key2=val2&amp;key3=val3...</pre>

The class definition

Class Domframework\Cli

Namespace Domframework

Description

/**
 Allow to interract with controllers and models from the CLI

Properties

No property available

Methods

public function __construct ()
/**
 The construtor define the catching of the errors

public function cliErrorHandler ( $errno, $errstr, $errfile, $errline)
/**
 The error handler for CLI : display error in STDERR
 @param integer $errno The error type
 @param string $errstr The string to send in error
 @param string $errfile The error file which generate the error
 @param integer $errline The line with an error

public function controllersDir ( $path)
/**
 Define the controllers path
 @param string|array $path The controllers pathes to use

public function modelsDir ( $path)
/**
 Define the models path
 @param string|array $path The models pathes to use

public function run ()
/**
 The real application launcher and helpers