We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

Calling CLI problem

Hi,

How do I deal with this error : PHP Fatal error: Class 'Phalcon\DI\FactoryDefault\CLI' not found

If I'm executing this command : php5 -v

PHP 5.5.10-1+deb.sury.org~precise+1 (cli) (built: Mar 27 2014 16:18:01) Copyright (c) 1997-2014 The PHP Group Zend Engine v2.5.0, Copyright (c) 1998-2014 Zend Technologies with Zend OPcache v7.0.3, Copyright (c) 1999-2014, by Zend Technologies

It says that I have CLI right ?

so why I'm getting the previous error when I execute this command : php5 cli.php controller task

On the web phalcon works very fine. Only on the command line I'm getting error.

I wish someone could answer me on that one.

Thank you !



125.8k
Accepted
answer
edited May '14

php5 -v is saying you have the CLI version of PHP5 installed. However, that doesn't necessarily mean you have Phalcon installed. The CLI version and Web version of PHP use different .ini files. It's possible Phalcon is installed in the .ini file the web version uses, but not the .ini file the CLI version uses.

Run this command:

php5 -r "phpinfo();" | grep "phalcon"

If Phalcon is available, it should print out something (likely just "phalcon") on the command line. If nothing is printed, then Phalcon isn't installed for the CLI version.

If that's the case, run

php5 -r "phpinfo();"

The beginning of that long output will show where the .ini files are being loaded from. On Debian, they're loaded from /etc/php5/cli/conf.d. You'll need to create an .ini file for Phalcon, just like you did for the web version.