LoginSignup
7
7

More than 5 years have passed since last update.

ZF2 で ZFTool を使う

Last updated at Posted at 2013-09-22

ZF1 にはプロジェクトのひな形を作ったり、モジュールやコントローラーを作成するための zf コマンドがありましたが、ZF2 にも同じようなものがあります。

ただし ZF2 本体には付いてこないので、別途インストールが必要です。

phar 単独で使用する

phar があるので、それをダウンロードすれば簡単に使用できます。

$ curl https://packages.zendframework.com/zftool.phar > zftool.phar

プロジェクトのひな形を作成したり、

$ php zftool.phar create project someproject
ZF2 skeleton application installed in someproject.
In order to execute the skeleton application you need to install the ZF2 library.
Execute: "composer.phar install" in someproject
For more info in someproject/README.md

ZF2 そのものをインストールしたりできます。

$ zftool.phar install zf somedirectory
The ZF library 2.2.4 has been installed in somedirectory.

プロジェクト内で使用する

プロジェクト内で使用する場合は zftool.phar よりも composer でプロジェクト自体に含めたほうが良いでしょう(というかプロジェクト内で zftool.phar を使う方法がわかりませんでした)。

$ composer require zendframework/zftool:dev-master

application.config.php で ZFTool モジュールを追加します。

application.config.php
<?php
return array(

    'modules' => array(
        'Application',
        'Album',
        'ZendDeveloperTools',
        'ZFTool', // ← これ!
    ),

    :

これで ZFTool が使用可能になりました。コンソールで次のように打つと Usage が表示されます。

$ php public/index.php

試しに ZFTool でモジュールの一覧を表示してみます。

$ php public/index.php modules
Modules installed:
Application
Album
ZendDeveloperTools

なお、application.config.php に ZFTool を追加しなくても composer によって生成される zf.php で実行することもできます。

$ vendor/bin/zf.php modules
Modules installed:
Application
Album
ZendDeveloperTools
7
7
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
7
7