ZFTool, command line for ZF2

Original author: Enrico Zimuel
  • Transfer
ZFTool is a command line component for managing applications written in Zend Framework 2. This tool is still under development. We have released an early version so you can start using it as soon as possible. In the current version, the tool can:

  • Create a ZF2 project by installing the skeleton application
  • Create new modules within an existing application
  • return a list of modules installed in the application;
  • return application configuration file;
  • install ZF2 libraries, choosing the necessary versions;

ZFTool is installed through composer or github . In addition, we compiled the PHAR file. You can download zftool.phar at https://packages.zendframework.com/zftool.phar . If you decide to use zftool.phar , you must add the address to the file in your system PATH variable. In this case, you can execute zftool.phar in the place where you typed the command.
To install using composer, run the following command in an environment shell:

$ composer require zendframework/zftool:dev-master

You can also install the component manually using github:
  1. make a clone using the command " git clone https://github.com/zendframework/ZFTool.git " or download ;
  2. extract the contents into the " vendor / ZFTool " of your ZF2 application;
  3. edit your " config / application.config.php " and add "ZFTool" to the array of modules.

After installation, you can either run the zf.php file in the ZFTool root folder or use zftool.phar (if you have ZFTool installed using composer or GitHub, you need to build zftool.phar by running the " bin / create-phar " script ).

Creating a new ZF2 project

The new ZF2 project is created by the command:
$ zf.php create project 
// or
$ zftool.phar create project 

This command will install the Zend Skeleton Application at the specified path.

Create a new module

Imagine that you want to create a new “Test” module in a local ZF2 application, you can do this:

$ zf.php create module Test
// or
$ zftool.phar create module Test

You can create a new module in the application by specifying different paths. The path is indicated by the last parameter.
$ zf.php create module Test 
// or
$ zftool.phar create module Test 

Getting a list of installed modules

The list of modules installed in ZF2 can be obtained as follows:
$ zf.php modules
// or
$ zftool.phar modules

This command should be executed from the root folder of the ZF2 application.

Getting ZF2 Application Configuration

You can read the configuration file (application.config.php) of the ZF2 application with the following command:
$ zf.php config
// or
$ zftool.phar config

Configuration is output using print_r function

ZF2 Installation

Using ZFTool you can install the Zend Framework 2 library of the desired version. To install the latest version of ZF in a specific path, use the command:
$ zf.php install zf 
// or
$ zftool.phar install zf 

If you want to install a specific version, specify a parameter with the version value. For example, to install version 2.0.4, use:
$ zf.php install zf  2.0.4
// or
$ zftool.phar install zf  2.0.4

In fact, you can install any version tag in ZF2 github repository (The name used for the version is obtained by removing the string “release-” from the tag name; for example, the tag “release-2.0.0” corresponds to version “2.0.0”)

Zftool.phar assembly

You can compile zftool.phar by running the command:
$ bin/create-phar

This command will compile the project file ZFTool zftool.phar folder bin directory .
For more information on ZFTool, you can refer to README.md on github.

Also popular now: