ZFTool is a command line tool to manage applications written in Zend Framework 2. This tool is still in development and we just released an early version that you can start to use. With this version of the tool you can:
- create a ZF2 project, installing a skeleton application;
- create a new module inside an existing application;
- get the list of all the modules installed inside an application;
- get the configuration file of a ZF2 application;
- install the ZF2 library choosing a specific version.
You can install ZFTool using composer or github. Moreover, we compiled it in a PHAR file. You can download the zftool.phar from this address https://packages.zendframework.com/zftool.phar. If you want to use the zftool.phar I suggest to add it in your PATH environment. In this way you can execute the zftool.phar script wherever you are.
To install using composer you have to execute the following command in a shell environment:
composer require zendframework/zftool:dev-master
You can also install manually using github, following the next steps:
- clone using "git clone https://github.com/zendframework/ZFTool.git" or download zipball;
- extract to "vendor/ZFTool" in your ZF2 application;
- edit your "config/application.config.php" and add "ZFTool" to modules array key.
After the installation you can execute the zf.php file inside the root folder of ZFTool or you can use the zftool.phar (if you have installed ZFTool using composer or github you need to compile the zftool.phar executing the script "bin/create-phar").
Create a new ZF2 project
You can create a new ZF2 project using the following command:
zf.php create project <path>
zftool.phar create project <path>
This command will install the Zend Skeleton Application inside the specified path.
Create a new module
Imagine that you want to create a new module "Test" on a local ZF2 application, you can execute the following command:
zf.php create module Test
zftool.phar create module Test
If you want to create a new module inside an application installed in a different path, you can add the path as last parameter:
zf.php create module Test <path>
zftool.phar create module Test <path>
Get the list of installed modules
You can get the list of all the modules installed in a ZF2 project using the following command:
zf.php modules <path>
zftool.phar modules <path>
This command must be executed from the root folder of a ZF2 application.
Get the configuration file of a ZF2 application
You can read the configuration file (application.config.php) of a ZF2 application using the command:
zf.php config <path>
zftool.phar config <path>
The output configuration is reported using the print_r function of PHP.
Install the ZF2 library
Using ZFTool you can install the Zend Fraemework 2 library choosing a specific version. For instance, you can install the latest version of ZF in a specific path using the following command:
zf.php install zf <path>
zftool.phar install zf <path>
If you want to install a specific version, you need to specify the version as last parameter. For instance, you can install the 2.0.4 version of ZF using the following command:
zf.php install zf <path> 2.0.4
zftool.phar install zf <path> 2.0.4
Basically, you can install all the tag version specified in the ZF2 github repository (the name used for the version is obtained removing the "release-" string from the tag name; for instance, the tag "release-2.0.0" is equivalent to the version number "2.0.0").
Compile the zftool.phar
You can compile the zftool.phar file executing the following command:
This command will compile the ZFTool project in the zftool.phar file under the bin folder.
For more information about ZFTool you can read the README.md in github.