Intellij IDEA de PHP

PHPのことは、ずっと毛嫌いしていたんですが、
何かに導かれて、『はじめてのPHP5』を買ってしまいました。

一生の不覚です。


初めてのPHP5 増補改訂版

初めてのPHP5 増補改訂版

  • 作者:David Sklar
  • 発売日: 2012/09/24
  • メディア: 大型本



早速、サンプルをコーディングするべく、PHPの環境をつくります。


brewPHPをインストール

$ brew tap homebrew/dupes
$ brew tap josegonzalez/homebrew-php
$ brew install php54

とかした記憶があります。詳しくは、こちらを参考に。
[ HomebrewでPHP環境 現時点でのまとめ - なんたらノート第三期ベータ]

windowsな人は、XAMPPでOK。次のxdebugも入るしね。

xdebugインストール

$ brew install php54-xdebug

/usr/local/etc/php/5.4/conf.d/ext-xdebug.iniに以下を追加します。

[xdebug]
zend_extension="/usr/local/Cellar/php54-xdebug/2.2.1/xdebug.so"
xdebug.profiler_append = 0
xdebug.profiler_enable = 1
xdebug.profiler_enable_trigger = 0
xdebug.profiler_output_dir = "/tmp"
xdebug.profiler_output_name = "cachegrind.out.%t-%s"
xdebug.remote_enable = 1
xdebug.remote_handler = "dbgp"
xdebug.remote_host = "127.0.0.1"
xdebug.trace_output_dir = "/tmp"

Intelij IDEAに、PHPプラグインをインストール

f:id:ryu-htn:20130420032223p:plain

インタープリタの設定

Preferences...>PHP

f:id:ryu-htn:20130420032516p:plain

Serversの設定

Preferences...>PHP>Servers

f:id:ryu-htn:20130420032730p:plain

Web Moduleを選択してプロジェクトを作成

f:id:ryu-htn:20130420032727p:plain

Run/Debug構成の設定

Run>Edit Configurations...

PHP Built-in Web Server追加

f:id:ryu-htn:20130420032731p:plain

apacheは面倒なので、PHP内蔵のBuilt-in Web Serverを使ってます。
ところで、Macの場合、なぜか、80番ポートは、sudo権限ないと、サーバー起動時に、permission deniedになるので、別の8080番とかに設定しておこう。(これにはハマった。)

PHP Web Application追加

f:id:ryu-htn:20130420032728p:plain

Run/Debugを実行

まず、Built-in Web ServerをRunで実行します。
その上で、Debugしたい場合は、PHP Web ApplicationをDebugで実行します。
テスト的にphpinfo()のphpファイルをブラウザで開ければOK。

f:id:ryu-htn:20130420032729p:plain



追記

configure: error: freetype.h not found.

brew install php54で、上記のエラーが発生!!
https://github.com/josegonzalez/homebrew-phpに記載されてるとおり、freetypeを入れなおして対処しました。

brew rm freetype jpeg libpng gd zlib
brew install freetype jpeg libpng gd zlib