I can't figure out how to run zf.php (Zend Framework 2 Tool) when bootstrapped with composer.
First I bootstrap composer and zftool according to the documentation:
$ mkdir tmp && cd tmp
$ curl -s https://getcomposer.org/installer | php
$ ./composer.phar require zendframework/zftool:dev-master
This works fine so far.
But when I try to run zf.php, I get errors:
$ vendor/zendframework/zftool/zf.php
PHP Warning: require_once(/Users/seb/tmp/vendor/zendframework/zftool/vendor/autoload.php): failed to open stream: No such file or directory in /Users/seb/tmp/vendor/zendframework/zftool/zf.php on line 13
Warning: require_once(/Users/seb/tmp/vendor/zendframework/zftool/vendor/autoload.php): failed to open stream: No such file or directory in /Users/seb/tmp/vendor/zendframework/zftool/zf.php on line 13
PHP Fatal error: require_once(): Failed opening required '/Users/seb/tmp/vendor/zendframework/zftool/vendor/autoload.php' (include_path='.:/opt/local/lib/php') in /Users/seb/tmp/vendor/zendframework/zftool/zf.php on line 13
Fatal error: require_once(): Failed opening required '/Users/seb/tmp/vendor/zendframework/zftool/vendor/autoload.php' (include_path='.:/opt/local/lib/php') in /Users/seb/tmp/vendor/zendframework/zftool/zf.php on line 13
What am I doing wrong? I'm using PHP 5.3.21 on Mac.
I also tested it on my Debian VServer with PHP 5.4, same error :(
Install Composer.phar locally
If you do not have the composer globally installed on your machine, you can install it locally in the project.
Installing Composer locally is a matter of just running the installer in your project directory (https://getcomposer.org/doc/00-intro.md).
Note: If the above fails for some reason, you can download the installer with php instead:
Install ZF2
Install ZFTools (Installation using Composer)
Create a symbolic link
zf.php (Zend Tool) will be installed in the vendor/bin folder. You may run it with php vendor/bin/zf.php.
In this case, I prefer symbolic link, for updating the zftools repository, I do not need to copy the file again.
Without installation, using the PHAR file
Another alternative to using the ZF tools, without creating scripts or aliases, and download the PHAR format.
Or you can download zftool.phar and use it.
Note 1:The @akond response is very good, I'm just presenting an alternative answer I like to use.
Note 2: This example was done on a windows machine using cygwin.
Good tutorial installation (ZF2 and ZF3)
Getting started: A skeleton application
Ref:
Zend Framework Tool (ZFTool)
You should copy zf.php into your root directory and run it from there.