getting "command not found: phalcon" after successfully installing phalcon/devtools via composer

787 Views Asked by At
Software: MacOS
Phalcon: 5.0.0RC4
Phalcon/Devtools: 4.2.0

I have newly created phalcon 5.0 repository. I successfully ran

composer install
composer require phalcon/devtools

however when I try to run a phalcon command I get

zsh: command not found: phalcon

I checked if it had installed successfully and tried reinstalling as well.
php -m returns that phalcon is installed too:

php -m | grep phalcon
phalcon

and the extension is there in the php.ini file

extension="phalcon.so"

Am I missing anything?

2

There are 2 best solutions below

1
Nicolai Fröhlich On BEST ANSWER

The phalcon/devtools package links the phalcon.php executable to your composer bin-dir.

Get it as follows:

composer config bin-dir

It defaults to ./vendor/bin. The installed symlink is ./vendor/bin/phalcon.php.

You can run the command as follows:

./vendor/bin/phalcon.php [..]

To ease access you can automatically add ./vendor/bin to your PATH (i.e. with direnv)

# .envrc
PATH_add ./vendor/bin

or you can create a ./bin dir in your project directory and symlink phalcon.php as phalcon into it.

mkdir ./bin
ln -sfn ./vendor/bin/phalcon.php ./bin/phalcon

Now you can add ./bin to your PATH:

export PATH="${PWD}/bin:${PATH}"

And invoke the phalcon CLI with:

phalcon [..]
0
The Blind Hawk On

Adding to Nicolai's answer, it is also possible to just call phalcon like so:

vendor/bin/phalcon commands

In my case, I didn't want to be able to call phalcon globally so I copied the file into the project directory and named it phalcon4
Then I edited the paths inside the file like so

$addpath = '/vendor/phalcon';
$GLOBALS['_composer_bin_dir'] = __DIR__ .$addpath;
$GLOBALS['_composer_autoload_path'] = __DIR__ .$addpath. '/..'.'/autoload.php';

// the rest of the code

include __DIR__ .$addpath. '/..'.'/phalcon/devtools/phalcon';

Now I can run the command like this:

php phalcon4 commands

Still, devtools 4.2 cannot run with phalcon 5 so the command just threw an error.