在早期Yii 1.0時代,借助于CWebLogRoute可以在指定Web頁面中輸入日志信息。因為現在廣泛使用Yii 2.X,所以此方式使用說明不再詳述。有興趣的讀者可參考參考資料1.
yii2-debug調試工具當屬Yii 2.0時代調試PHP代碼的首選。此擴展為 Yii 2 應用程序提供了一個調試器。當使用此擴展時, 每個頁面的底部將出現一個調試器工具欄。此擴展還提供了 一系列獨立的頁面來顯示更詳細的調試信息。
工具欄顯示當前打開的頁面信息,此時調試器可以用來分析你以前 所收集的數據(例如,確認變量的值)。
在這些工具中您可以:
所有這些信息可按要求提供,讓您更好的重新查看過去的請求信息。
本文后面引用4中簡潔、準確記錄了Yii2-debug的使用方法;在此不再贅述。
剛開始Yii開發時,Yii2-debug調試面板并不顯示。參考下圖,其中是一個簡單的視圖。
1-12, 'all' or Enter to continue:
輸入 1,將安裝根目錄修改為 /usr/local/pear;
輸入 4,將命令安裝到 /usr/local/bin 目錄;
其它選項默認即可,一路回車。
也就是說,在上面【:】后面輸入1,然后在隨后的提示行中把安裝根目錄的位置修改為/usr/local/pear,再輸入4來修改命令安裝位置,此時輸入/usr/local/bin。之后,一路回車下來,即可完美安裝PEAR了。
輸入命令行:pear version,我的電腦結果輸出如下:
PEAR Version: 1.10.5
PHP Version: 7.1.16
Zend Engine Version: 3.1.0
Running on: Darwin undefined.hostname.localhost 17.7.0 Darwin Kernel Version 17.7.0: Thu Jun 21 22:53:14 PDT 2018; root:xnu-4570.71.2~1/RELEASE_X86_64 x86_64
理論上是使用如下命令:
pecl install xdebug
但是,出現如下錯誤提示:
Password:
WARNING: channel "pecl.php.net" has updated its protocols, use "pecl channel-update pecl.php.net" to update
downloading xdebug-2.6.1.tgz ...
Starting to download xdebug-2.6.1.tgz (283,961 bytes)
.................................................done: 283,961 bytes
79 source files, building
running: phpize
Configuring for:
PHP Api Version: 20160303
Zend Module Api No: 20160303
Zend Extension Api No: 320160303
Cannot find autoconf. Please check your autoconf installation and the
$PHP_AUTOCONF environment variable. Then, rerun this script.
ERROR: `phpize' failed
于是,先使用brew安裝了autoconf:
brew install autoconf
使用如下命令:
sudo pecl install xdebug
出現很長的跨屏幕提示,大致意思是下載后要重新編譯一下才得到xdebug.so文件。
注意,上面命令編譯后的xdebug.so所在的位置要搞清楚。我的機器上是生成到了路徑/usr/lib/php/extensions/no-debug-non-zts-20160303。
1.https://blog.csdn.net/calm_thinker/article/details/51452695,《yii 如何使用 CWebLogRoute 記錄和調試變量》。2.https://www.yiiframework.com/doc/api/1.1/CWebLogRoute
3.https://github.com/yiisoft/yii2-debug/blob/master/docs/guide-zh-CN/README.md
4.https://github.com/yiisoft/yii2-debug/blob/master/docs/guide-zh-CN/installation.md。
5.https://blog.csdn.net/json_vip/article/details/79324524
6.https://xdebug.org/docs/install
7.https://medium.com/@romaninsh/install-php-7-2-xdebug-on-macos-high-sierra-with-homebrew-july-2018-d7968fe7e8b8
br/>2.https://www.yiiframework.com/doc/api/1.1/CWebLogRoute
3.https://github.com/yiisoft/yii2-debug/blob/master/docs/guide-zh-CN/README.md
4.https://github.com/yiisoft/yii2-debug/blob/master/docs/guide-zh-CN/installation.md。
5.https://blog.csdn.net/json_vip/article/details/79324524
6.https://xdebug.org/docs/install
7.https://medium.com/@romaninsh/install-php-7-2-xdebug-on-macos-high-sierra-with-homebrew-july-2018-d7968fe7e8b8
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。