Zend Framework 2 : ZFTool – Zend Framework 2 Module to Ease Development
ZFTool is an utility module for maintaining modular Zend Framework 2 applications. It runs from the command line and can be installed as ZF2 module or as PHAR.
It currently can show installed modules, create a new module, or create a project.
1. Installation
Open your composer.json in your skeleton application :
{ "name": "zendframework/skeleton-application", "description": "Skeleton Application for ZF2", "license": "BSD-3-Clause", "keywords": [ "framework", "zf2" ], "homepage": "http://framework.zend.com/", "require": { "php": ">=5.3.3", "zendframework/zendframework": "2.*", "zendframework/zftool": "dev-master" } }
and add “zendframework/zftool”: “dev-master” in require, and run :
php composer.phar self-update && php composer.phar update
OR, you can remove above step by run the following :
composer require zendframework/zftool:dev-master
and You will see process like this :
and your downloaded ZFTool show in your vendor folder.
Last step for installation, edit your config/application.config.php and add ZFTool to modules array.
2. Using ZFTool
a. Getting started : Show list commands
Type :
php public/index.php
and you will see the following list :
b. show modules
Type :
php public/index.php modules
and you will see like the following :
c. create module
Type :
//testmodule is name of module we want to create php public/index.php create module testmodule
and if success, you will see like the following :
d. create a project
Type :
//new_prj is name of project we want to create php public/index.php create project ../new_prj
and if success, you will see like the following :
References :
https://github.com/zendframework/ZFTool
I’m getting the follwing error when composer update:
– zendframework/zftool dev-master requires zendframework/zend-version >=2.0.0 -> no matching package found.
This is my composer.json:
“name”: “zendframework/skeleton-application”,
“description”: “Skeleton Application for ZF2”,
“license”: “BSD-3-Clause”,
“keywords”: [
“framework”,
“zf2”
],
“homepage”: “http://framework.zend.com/”,
“minimum-stability”: “alpha”,
“require”: {
“php”: “>=5.3.3”,
“zendframework/zendframework”: “2.*”,
“zendframework/zend-config”: “2.0.*”,
“zendframework/zend-http”: “2.0.*”,
“phpunit/phpunit”: “3.7.*”,
“doctrine/common” : “>=2.1”,
“doctrine/migrations” : “dev-master”,
“doctrine/doctrine-orm-module”: “0.*”,
“zendframework/zend-developer-tools”: “dev-master”,
“bjyoungblood/BjyProfiler”: “dev-master”,
“zendframework/zftool”: “dev-master”
}
Thanks in advance, great blog!
try to change minimum-stability to dev.
You’re welcome 😉
That did it! thx again!
You’re welcome 😉
I’m having problems creating a module, i get the following error:
PHP Parse error: syntax error, unexpected ‘[‘ in /var/www/zf2_new_app/vendor/zendframework/zftool/src/ZFTool/Controller/CreateController.php on line 53
I’m running “php public/index.php create module mymodule” in my root zf2 application folder,
Thanks again!
what line 53 code ? i’m using mac and it’s just work
here’s the line:
$tmpSkeleton = $tmpDir . ‘/’ . rtrim($zip->statIndex(0)[‘name’], “/”);
I’m in a linux dev server
my temporary answer, clone my old fork : https://github.com/samsonasik/ZFTool ,
the line 53 is not same as yours. I think it’s your php version problem in $zip->statIndex(0)[‘name’] that should be only for php 5.4 🙂
I’m seeing the same line 53 of /src/ZFTool/Controller/CreateController.php on your git
unless i’m missing something…
Oops, You’re right, change line 53 with this :
I just sent a PR here : https://github.com/zendframework/ZFTool/pull/13 , Thank You 😉
That did it, thx again man!
You’re welcome 😉
Put minimun-stability like dev is not fix to problem, is a workaroud, here he removes the zendframework 2.0.6 and clone the zendframework in dev…this a risk for development to put in production.
oh, I written an email for you, and you dont response me, all right, i know that youtput your email for anyone write an email for you.
thanks
I don’t recommend to write minimum-stability, but if it needed, it should be dev and you should just update, not re-install. You can go to https://github.com/zendframework/ZFTool and click ZIP download button anyway.
I didn’t find email from you, maybe re-send again ? 🙂
When I use php public/index.php create project new_prj on the console, It returns ” I can’t use the API of github”. Do you know what this is?
No.
very useful for beginers
thanks
Hello Samsonasik
thank you so much for this tutorial; i was really stock on this issue; you really just saved me. thanks