# EclipseでPHPの開発環境を構築する

- URL: https://www.blog.danishi.net/2019/04/13/post-309/
- 公開日: 2019-04-13
- 更新日: 2025-05-31
- 著者: danishi
- カテゴリー: やってみた
- タグ: PHP, Eclipse, XAMPP
- この記事には広告（アフィリエイトリンク）が含まれています。

どうも。

私が普段PHP書くときはVS Codeを使っているのですが…\
EclipseでのPHP開発もメジャーだということでちょっと試してみようと思います。

Eclipseは昔Javaで仕事していた時に使ってて、Javaの統合開発環境というイメージが強いのですが、PHPの開発はやりやすいのでしょうか…。

[よくわかるPHPの教科書 【PHP7対応版】](https://www.amazon.co.jp/dp/4839964688?tag=danishi0a-22)（Amazon、PR）

## インストール

### ダウンロード

公式サイトよりPleiadesの最新版をダウンロードします。\
PleiadesはEclipseと日本語化プラグインが一体になったインストールパッケージですね。\
[https://mergedoc.osdn.jp/](https://mergedoc.osdn.jp/)

[![](https://www.blog.danishi.net/wp-content/uploads/2019/04/image-18-1024x622.png)](https://www.blog.danishi.net/wp-content/uploads/2019/04/image-18.png)

私の環境に合わせ、Windows 64bitのPHPのFull Editionを選択します。

[![](https://www.blog.danishi.net/wp-content/uploads/2019/04/image-22-1024x174.png)](https://www.blog.danishi.net/wp-content/uploads/2019/04/image-22.png)

パッケージ内にXAMPPやxdebugも含まれているようですね。

### インストール

Eclipseはインストーラー型のソフトウェアではないので、ダウンロードしたZIPを展開して、お好みの場所に配置します。\
私はこの手のポータブルアプリは、ユーザディレクトリの配下にtoolsというディレクトリを切ってまとめているのでそこに置きます。

[![](https://www.blog.danishi.net/wp-content/uploads/2019/04/image-23-1024x208.png)](https://www.blog.danishi.net/wp-content/uploads/2019/04/image-23.png)

eclipseフォルダの中に入って、「eclipse.exe」を実行します。\
XAMPPの構成が一緒に行われます。

[![](https://www.blog.danishi.net/wp-content/uploads/2019/04/image-24-1024x470.png)](https://www.blog.danishi.net/wp-content/uploads/2019/04/image-24.png)

ワークスペース（プロジェクトフォルダのベース）になるディレクトリを選択します。\
XAMPPで実行するにはそのままの方がいいでしょう。\
後で切り替えもできます。

[![](https://www.blog.danishi.net/wp-content/uploads/2019/04/image-25-1024x771.png)](https://www.blog.danishi.net/wp-content/uploads/2019/04/image-25.png)

Eclipseが立ち上がりました。

## PHPプロジェクトを作成する

それでは簡単なPHPプロジェクトを作っていきます。

[![](https://www.blog.danishi.net/wp-content/uploads/2019/04/image-26.png)](https://www.blog.danishi.net/wp-content/uploads/2019/04/image-26.png)

ファイル->新規->PHPプロジェクトを選択します。

[![](https://www.blog.danishi.net/wp-content/uploads/2019/04/image-27-950x1024.png)](https://www.blog.danishi.net/wp-content/uploads/2019/04/image-27.png)

「新規 PHP プロジェクト」のダイアログが開くので設定していきます。

**プロジェクト名**\
プロジェクト名を設定します設定した名前がプロジェクトフォルダの名前になります。

**PHP バージョン**\
利用するPHPのバージョンを指定します。

**JavaScript サポート**\
JavaScriptのコードインテリジェントを有効にするかを選択します。

**ワーキング・セット**\
ワーキング・セットはワークスペース内のプロジェクトをまとめるグループのことです。\
必要なら設定しましょう。

「次へ」を押すと、フォルダの追加やインクルードパスの設定が行えますが、「完了」でプロジェクトを作成しましょう。

[![](https://www.blog.danishi.net/wp-content/uploads/2019/04/image-28-1024x457.png)](https://www.blog.danishi.net/wp-content/uploads/2019/04/image-28.png)

プロジェクトが出来上がるので、右クリックして新規PHPファイルを作ります。

[![](https://www.blog.danishi.net/wp-content/uploads/2019/04/image-29-1024x989.png)](https://www.blog.danishi.net/wp-content/uploads/2019/04/image-29.png)

ファイル名を設定して「完了」を押します。

[![](https://www.blog.danishi.net/wp-content/uploads/2019/04/image-30.png)](https://www.blog.danishi.net/wp-content/uploads/2019/04/image-30.png)

簡単なテストコードを書いて実行してみましょう。

[![](https://www.blog.danishi.net/wp-content/uploads/2019/04/image-31-1024x665.png)](https://www.blog.danishi.net/wp-content/uploads/2019/04/image-31.png)

Webサーバを起動するため、\
pleiadesのフォルダに行きxamppフォルダ内の「xampp-control.exe」を実行。\
Apacheを起動します。

[![](https://www.blog.danishi.net/wp-content/uploads/2019/04/image-32-1024x362.png)](https://www.blog.danishi.net/wp-content/uploads/2019/04/image-32.png)

「PHP Web アプリケーション」として実行します。

[![](https://www.blog.danishi.net/wp-content/uploads/2019/04/image-33-1024x365.png)](https://www.blog.danishi.net/wp-content/uploads/2019/04/image-33-e1555144588283.png)

デバッグモードになり実行が止まるので、再開を押して処理を進めます。

[![](https://www.blog.danishi.net/wp-content/uploads/2019/04/image-34-1024x399.png)](https://www.blog.danishi.net/wp-content/uploads/2019/04/image-34.png)

ブラウザプレビューが表示され、実行が確認できました。

ただ、プロジェクト作成時PHPのバージョンを7.3にしたはずが5.6になっています。\
XAMPPのPHPモジュールを切り替える必要がありそうですね。

## PHPバージョンの切り替え

折角なので最新バージョンのPHP7.3を使えるようにします。\
PHPのサイトに行き最新版のZIPをダウンロードします。

[https://windows.php.net/download#php-7.3](https://windows.php.net/download#php-7.3)

[![](https://www.blog.danishi.net/wp-content/uploads/2019/04/image-35-1024x202.png)](https://www.blog.danishi.net/wp-content/uploads/2019/04/image-35.png)

EclipseとXAMPPをいったん終了させて、もともとあった「pleiades\\xampp\\php」フォルダを「php5.6」にリネームし、ダウンロードしたZIPを回答しphpフォルダとして配置します。

「pleiades\\xampp\\apache\\conf\\extra\\httpsd-xampp.conf」を開き「php5」を「php7」に置換します。

新しく作ったphpフォルダ内の「php.ini-development」をリネームし「php.ini」にします。\
さらに古い方の「php5.6」フォルダの「php.ini」を開き、「pleiades」で検索。\
以下のテキストを探し新しい方の「php.ini」に追加or上書きします。

```ini
error_log="C:\Users\snish\tools\pleiades\xampp\php\logs\php_error_log"
include_path = C:\Users\snish\tools\pleiades\xampp\php\PEAR
extension_dir = "C:\Users\snish\tools\pleiades\xampp\php\ext"
upload_tmp_dir = "C:\Users\snish\tools\pleiades\xampp\tmp"
browscap = "C:\Users\snish\tools\pleiades\xampp\php\extras\browscap.ini"
session.save_path = "C:\Users\snish\tools\pleiades\xampp\tmp"
curl.cainfo = "C:\Users\snish\tools\pleiades\xampp\apache\bin\curl-ca-bundle.crt"
openssl.cafile = "C:\Users\snish\tools\pleiades\xampp\apache\bin\curl-ca-bundle.crt"
;----------------------------
; Pleiades All in One CUSTOM
;----------------------------
date.timezone = Asia/Tokyo
zend_extension = "C:\Users\snish\tools\pleiades\xampp\php\ext\php_xdebug.dll"
xdebug.remote_enable = 1
xdebug.remote_autostart = 1
```

古い方のextrasフォルダの中身をすべて新しい方に上書きします。

「php_xdebug.dll」が必要なので下記のサイトにアクセスし、バージョンにあったDLLをダウンロードします。\
[https://xdebug.org/wizard.php](https://xdebug.org/wizard.php)

テキストボックスにコマンドプロンプトで「php -i | clip」をした結果を張り付けてボタンを押すと、対象のDLLのダウンロードリンクが表示されます。

ダウンロードしたものを「php_xdebug.dll」にリネームして「ext」フォルダに配置します。

これで準備完了。EclipseとXAMPP（Apache）を起動して、再度Helloプロジェクトを実行してみる。

「Could not initialize class org.eclipse.php.internal.debug.core.debugger.DebuggerSettingsManager」みたいなエラーが出たので一度ワークスペースを削除し、再度ワークスペースとHelloプロジェクトを作り直します。

[![](https://www.blog.danishi.net/wp-content/uploads/2019/04/image-36-1024x555.png)](https://www.blog.danishi.net/wp-content/uploads/2019/04/image-36.png)

実行するとPHPのバージョンが上がったことが確認できました！

## 追加の設定

使い勝手良くするためにいくつか設定しておきます。

### ダークテーマの設定

デフォルトのテーマは白が基調で目に痛いのでダークテーマに変更します。

[![](https://www.blog.danishi.net/wp-content/uploads/2019/04/image-37-1024x981.png)](https://www.blog.danishi.net/wp-content/uploads/2019/04/image-37.png)

メニューバーのウィンドウから設定->外観、で「ルック＆フィール」にダークを選択。\
Eclipseを再起動するとダークテーマが適用されます。

[![](https://www.blog.danishi.net/wp-content/uploads/2019/04/image-38-1024x729.png)](https://www.blog.danishi.net/wp-content/uploads/2019/04/image-38.png)

### JVM使用メモリ増量

Javaの頃からやってた設定。\
Eclipseが確保するメモリの初期値と限界値を引き上げて処理を早くします。

[![](https://www.blog.danishi.net/wp-content/uploads/2019/04/image-39.png)](https://www.blog.danishi.net/wp-content/uploads/2019/04/image-39.png)

これが今の使用量ですね。

eclipseフォルダ直下にあるeclipse.iniを開いて、以下を追記します。

```text
-Xms512m
-Xmx1024m
```

「-Xms」は起動時のヒープサイズ、「-Xmx」最大ヒープサイズです。\
再度起動すると。

[![](https://www.blog.danishi.net/wp-content/uploads/2019/04/image-40.png)](https://www.blog.danishi.net/wp-content/uploads/2019/04/image-40.png)

確保しているメモリが増えましたね。

以上！\
イマイチ慣れないですが、それなりに使えそうですね。\
個人的にスクリプト言語はIDEより軽量なエディタで書きたい派ですが…。

でわ。

[JavaデベロッパーのためのEclipse完全攻略4.x対応版](https://www.amazon.co.jp/dp/4797385294?tag=danishi0a-22)（Amazon、PR）
