command-linecomposer-phpphalconphalcon-devtools

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


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?


Solution

  • 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 [..]