Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.



I have a problem with Cli which is working on localhost(apache2):


use Phalcon\DI\FactoryDefault\Cli as CliDI,
    Phalcon\Cli\Console as ConsoleApp,
    Phalcon\Db\Adapter\Pdo\Mysql as DbAdapter;

$di = new CliDI();
define('__URL__', 'milan.local');
defined('APPLICATION_PATH') || define('APPLICATION_PATH', realpath(dirname(__FILE__)));

$loader = new \Phalcon\Loader();

        APPLICATION_PATH . '/tasks'

    'Models\Settings' => APPLICATION_PATH . '/models/settings/',
    'Models\User' => APPLICATION_PATH . '/models/user/',
    'Library' => APPLICATION_PATH . '/library/'

if (is_readable(APPLICATION_PATH . '/config/config.php')) {
    $config = include APPLICATION_PATH . '/config/config.php';
    $di->set('config', $config);

$console = new ConsoleApp();

$arguments = array();
foreach ($argv as $k => $arg) {
    if ($k == 1) {
        $arguments['task'] = $arg;
    } elseif ($k == 2) {
        $arguments['action'] = $arg;
    } elseif ($k >= 3) {
        $arguments['params'][] = $arg;

$di->set('db', function () use ($config) {
    return new DbAdapter(array(
        'host' => $config->database->host,
        'username' => $config->database->username,
        'password' => $config->database->password,
        'dbname' => $config->database->dbname,
        'charset' => $config->database->charset,

define('CURRENT_TASK',   (isset($argv[1]) ? $argv[1] : null));
define('CURRENT_ACTION', (isset($argv[2]) ? $argv[2] : null));

try {
} catch (\Phalcon\Exception $e) {
    echo $e->getMessage();

but at the server i have an error:

PHP Fatal error: Class 'Phalcon\DI\FactoryDefault\Cli' not found in /var/www/clients/client1/web2/web/app/cli.php on line 7

What am I doing wrong?

Please, help me.

Regards, nansss

edited Aug '16

First of all, CLI apps have nothing to do with the webserver (apache2) :]

As for you problem, you most probably haven't enabled the phalcon extension. If you installed php from the package manager, you can do this:

echo '' > /etc/php5/mods-available/phalcon.ini
php5enmod phalcon

Or you can manually set it up (only for the cli SAPI):

echo '' >> /etc/php5/cli/php.ini


echo '' >> /etc/php5/php-cli.ini

The point is, add to your ini file


I have the phalcon extension on nginx /etc/php5/fpm/conf.d/30-phalcon.ini and mvc application works normally


As already wrote, nginx and fpm don't havy ANYTHING to do with CLI app. Are you have the same file under /etc/php5/cli/conf.d ?


Thanks. There was my mistake. I had /etc/php5/cli/conf.d/ instead /etc/php5/cli/conf.d/30-phalcon.ini

Now it is everything ok so topis to close.