How to install Zend Framework 2 tool with composer

I cannot figure out how to run zf.php (Zend Framework 2 Tool) when loading with composer.

First I load 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 

It works great 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 am using PHP 5.3.21 on a Mac.

I also tested it on my VServer VServer with PHP 5.4, same error :(

+6
source share
2 answers

Copy zf.php to the root directory and run it from there.

 $ mkdir tmp && cd tmp $ curl -s https://getcomposer.org/installer | php $ ./composer.phar require zendframework/zftool:dev-master $ cp vendor/zendframework/zftool/zf.php . $ php zf.php 
+9
source

Install Composer.phar locally

If you do not have a composer built-in to your computer, you can install it locally in the project.

Installing Composer locally is simply starting the installer in your project directory ( https://getcomposer.org/doc/00-intro.md ).

 curl -sS https://getcomposer.org/installer | php 

Note If for some reason you cannot do this, you can download the installer instead of php:

 php -r "readfile('https://getcomposer.org/installer');" | php 

Install ZF2

 git clone git://github.com/zendframework/ZendSkeletonApplication.git --recursive cd ZendSkeletonApplication php composer.phar self-update php composer.phar install 

Install ZFTools (installation using Composer )

 php composer.phar require zendframework/zftool:dev-master php composer.phar install 

Create a symbolic link

zf.php (Zend Tool) will be installed in the / bin provider folder. You can run it with php vendor / bin / zf.php.

 ln -s vendor/zendframework/zftool/zf2.bat zftools chmod +x zftools ./zftools 

In this case, I prefer a symlink, to update the zftools repository I no longer need to copy the file.

Without installation using a PHAR file

Another alternative to using ZF tools without creating scripts or aliases and downloading the PHAR format.

 wget https://packages.zendframework.com/zftool.phar --no-check-certificate php zftool.phar version ZFTool - Zend Framework 2 command line Tool The ZFTool is using Zend Framework 2.2.4 

Or you can download zftool.phar and use it.

Note 1: @ akond's answer is very good, I just present an alternative answer that I like to use.

Note 2: This example was run on a Windows machine using cygwin.

Good installation tutorial (ZF2 and ZF3)

Getting started: skeletal application

Ref:

Zend Framework Tool (ZFTool)

+5
source

All Articles