[Grunt & Yeoman] grunt-php で PHP のビルドインサーバを使う
grunt-php でプレビューサーバを立ち上げます。
[markdown]
> * [sindresorhus/grunt-php](https://github.com/sindresorhus/grunt-php)
> * [Grunt: サーバを立ててLiveReload をつかう | deadwood](https://www.d-wood.com/blog/2013/11/15_5033.html)
## インストール
“`prettyprinted
% npm install grunt-php –save-dev
:
npm ERR! peerinvalid The package grunt does not satisfy its siblings’ peerDependencies requirements!
npm ERR! System Darwin 13.3.0
npm ERR! command “node” “/usr/local/bin/npm” “install” “grunt-php” “–save-dev”
npm ERR! cwd /Users/****/projects/foo
npm ERR! node -v v0.10.30
npm ERR! npm -v 1.4.24
npm ERR! code EPEERINVALID
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /Users/****/projects/foo/npm-debug.log
npm ERR! not ok code 0
“`
ちなみにエラーが出ていますが、そのままで進めます。
> * [peerDependency — MOL](http://t32k.me/mol/log/peerdependency/)
## Gruntfile
他に grunt-watch の `livereload: true` 設定を加えれば、リロードも設定できます。
> * [PHP と Grunt で ブラウザのアドオンを使わずに LiveReload する – ngの日記](http://ngyuki.hatenablog.com/entry/2013/12/13/102214)
“`ruby:Gruntfile.coffee
# grunt-php
php:
server:
options:
port: 8000
hostname: ‘localhost’
base: ‘<%= dir.dest %>‘
keepalive: false,
open: true
“`
なお `keepalive: false` を入れないと、grunt-php 以降の watch タスクが実行されませんので入れておきましょう。
> * [grunt-phpでPHPのLivereloadをする方法 – Qiita](http://qiita.com/maccotsan/items/d6796de1f89bcaa53893)
気軽にお試しできて良いかもしれません。
grunt-connect の代わりに設定しておくことにします。
## 補遺
grunt-phpunit というのもあるよう。
> * [PHP 開発でも Grunt を使う – ngの日記](http://ngyuki.hatenablog.com/entry/2013/12/03/231619)
[/markdown]