📜 ⬆️ ⬇️

ZFTool, command line for ZF2

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 quickly start using it. In the current version the tool can:


ZFTool is installed via composer or github . In addition, we compiled a PHAR file. You can download zftool.phar at https://packages.zendframework.com/zftool.phar . If you decide to use zftool.phar , you need to 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 the composer, run the following command in the shell environment:

$ 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 to the ZFTool module array.

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

Creating a new ZF2 project


A new ZF2 project is created by the command:
 $ zf.php create project <path> // or $ zftool.phar create project <path> 

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

Creating a new module


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

 $ 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 specified by the last parameter.
 $ zf.php create module Test <path> // or $ zftool.phar create module Test <path> 


Getting a list of installed modules


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

This command must 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 using the following command:
 $ zf.php config<path> // or $ zftool.phar config<path> 

The configuration is output using the print_r function.

ZF2 installation


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

If you want to install a specific version, specify the parameter with the version value. For example, to install version 2.0.4, use:
 $ zf.php install zf <path> 2.0.4 // or $ zftool.phar install zf <path> 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 "release-" line from the tag name; for example, the "release-2.0.0" tag corresponds to the "2.0.0" version)

Build zftool.phar


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

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

Source: https://habr.com/ru/post/166385/


All Articles