LoginSignup
1
4

More than 5 years have passed since last update.

VSCodeでCodeigniterをデバッグ

Last updated at Posted at 2016-12-25

2017/01/15追記
このやり方だと、function index()しかデバッグできませんね^^;
parameter の渡し方がわからないので、とりあえずLaunch currently open scriptモードを使用してますorz

初稿はここから

そろそろ初心者を抜け出したくて、デバッグ環境を整えることにした。
既存環境のメンテナンスから始めようと思い、CodeIgniter のデバッグ環境を VSCode 上に構築します。

環境

Windows7
VSCode 1.8.1
CodeIgniter 3.1.2
xdebug 2.5.0-7.0

xdebug の導入

https://xdebug.org/wizard.php
で導入すべき xdebug を確認。導入。
php.ini へ以下を追記。

zend_extension = C:\xampp\php\ext\php_xdebug-2.5.0-7.0-vc14.dll
xdebug.remote_enable=1
xdebug.remote_host="127.0.0.1"
xdebug.remote_port=9000
xdebug.remote_autostart = 1

zend_extension の設定は、xdebug 導入時にメッセージとして記載があったため、スンナリ行ったけど、それ以外の設定は、実はあんまり理解できていない^^;動かなかったので、ググって追加したおまじない。

VSCode の設定

VSCode のデバッグボタンを押し、設定ボタンをさらに押して、lunch.json を開く。
CodeIgniter 用の設定を追加。

        {
            "name": "for codeigniter",
            "type": "php",
            "request": "launch",
            "program": "${workspaceRoot}\\public\\index.php",
            "args": [
                "/${fileBasenameNoExtension}"
            ],
            "stopOnEntry": true,
            "port": 9000
        },

あ、ディレクトリの設定は、
https://github.com/kenjis/codeigniter-composer-installer
でインストールした前提になってます。
Controller 配下にディレクトリを作って、スクリプトを書いている場合、"args" を"/hoge/${fileBasenameNoExtension}"みたいにすれば動くけど、スマートな方法模索中^^;

xdebug の導入に思った以上に時間がかかってしまった。。。

1
4
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
1
4