最近2018中文字幕在日韩欧美国产成人片_国产日韩精品一区二区在线_在线观看成年美女黄网色视频_国产精品一区三区五区_国产精彩刺激乱对白_看黄色黄大色黄片免费_人人超碰自拍cao_国产高清av在线_亚洲精品电影av_日韩美女尤物视频网站

RELATEED CONSULTING
相關(guān)咨詢(xún)
選擇下列產(chǎn)品馬上在線(xiàn)溝通
服務(wù)時(shí)間:8:30-17:00
你可能遇到了下面的問(wèn)題
關(guān)閉右側(cè)工具欄

新聞中心

這里有您想知道的互聯(lián)網(wǎng)營(yíng)銷(xiāo)解決方案
macOSPHP7怎么增加X(jué)debug

本篇內(nèi)容主要講解“macOS PHP7怎么增加X(jué)debug”,感興趣的朋友不妨來(lái)看看。本文介紹的方法操作簡(jiǎn)單快捷,實(shí)用性強(qiáng)。下面就讓小編來(lái)帶大家學(xué)習(xí)“macOS PHP7怎么增加X(jué)debug”吧!

創(chuàng)新互聯(lián)擁有十多年成都網(wǎng)站建設(shè)工作經(jīng)驗(yàn),為各大企業(yè)提供網(wǎng)站設(shè)計(jì)、成都做網(wǎng)站服務(wù),對(duì)于網(wǎng)頁(yè)設(shè)計(jì)、PC網(wǎng)站建設(shè)(電腦版網(wǎng)站建設(shè))、app軟件開(kāi)發(fā)公司、wap網(wǎng)站建設(shè)(手機(jī)版網(wǎng)站建設(shè))、程序開(kāi)發(fā)、網(wǎng)站優(yōu)化(SEO優(yōu)化)、微網(wǎng)站、域名注冊(cè)等,憑借多年來(lái)在互聯(lián)網(wǎng)的打拼,我們?cè)诨ヂ?lián)網(wǎng)網(wǎng)站建設(shè)行業(yè)積累了很多網(wǎng)站制作、網(wǎng)站設(shè)計(jì)、網(wǎng)絡(luò)營(yíng)銷(xiāo)經(jīng)驗(yàn),集策劃、開(kāi)發(fā)、設(shè)計(jì)、營(yíng)銷(xiāo)、管理等網(wǎng)站化運(yùn)作于一體,具備承接各種規(guī)模類(lèi)型的網(wǎng)站建設(shè)項(xiàng)目的能力。

macOS系統(tǒng)PHP7增加X(jué)debug

Apple在發(fā)布macOS High Sierra后,系統(tǒng)也終于自帶了php v7.1,相比于之前,如果想使用php7,還得額外想辦法( Homebrew或者 php-osx)而言著實(shí)方便了不少。

但是,系統(tǒng)自帶的PHP只有基礎(chǔ)的配置,如果想做PHP開(kāi)發(fā),Xdebug還是必須的,以下就總結(jié)一下如何在macOS High Sierra中為系統(tǒng)自帶的PHP增加X(jué)debug模塊?!就扑]:PHP7教程】

基礎(chǔ)環(huán)境( macOS 及 PHP 信息)

  • macOS High Sierra: v10.13.3

  • PHP: v7.1.7

安裝Xdebug

Xdebug官網(wǎng)安裝文檔中有MAC推薦的方式,鑒于系統(tǒng)自帶的是PHP是v7.1.7,所以在選擇的時(shí)候,需要選擇php71-xdebug這個(gè)安裝包。

macOS PHP7怎么增加X(jué)debug

另外由于brew中的php71-xdebug依賴(lài)于php71的,所以建議加上--without-homebrew-php這個(gè)參數(shù),這樣的話(huà)brew就會(huì)忽略安裝php71。

brew install php71-xdebug --without-homebrew-php

不過(guò)這個(gè)時(shí)候,或許你會(huì)碰到下面這樣的報(bào)錯(cuò):

phpize
grep: /usr/include/php/main/php.h: No such file or directory
grep: /usr/include/php/Zend/zend_modules.h: No such file or directory
grep: /usr/include/php/Zend/zend_extensions.h: No such file or directory
Configuring for:
PHP Api Version:
Zend Module Api No:
Zend Extension Api No:

提示缺失依賴(lài),從而導(dǎo)致phpize無(wú)法正常工作,phpize是用來(lái)準(zhǔn)備 PHP 擴(kuò)展庫(kù)的編譯環(huán)境的,理論上系統(tǒng)自帶的PHP應(yīng)該是有phpize的,但是沒(méi)有在/usr/include/php/*里面找到它需要的模塊,并且檢索/usr/include時(shí)發(fā)現(xiàn)這個(gè)目錄根本不存在。

Google了一圈,解決問(wèn)題,就需要在/usr/include中補(bǔ)全相關(guān)的內(nèi)容,在OSX v10.10以前系統(tǒng),需要手動(dòng)做軟鏈來(lái)解決:

sudo ln -s /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include /usr/include

但是v10.11以后的系統(tǒng)重寫(xiě)了安全策略,所以會(huì)遇到權(quán)限問(wèn)題(sudo也不行):

ln: /usr/include: Operation not permitted

不過(guò)好在Apple為開(kāi)發(fā)人員準(zhǔn)備了Xcode,這是一個(gè)很強(qiáng)大的工具,但是體積也很大(下載安裝有點(diǎn)慢),而一般我們只需要它提供的Command Line Tools就夠了,上面的問(wèn)題,其實(shí)只要安裝Command Line Tools就可以解決:

xcode-select --install

接下來(lái),跟著提示做,安裝、同意協(xié)議...
macOS PHP7怎么增加X(jué)debug

等待安裝結(jié)束以后,再用 brew來(lái)安裝 php71-xdebug:

brew install php71-xdebug --without-homebrew-php

一切結(jié)束以后,brew會(huì)給出提示:

To finish installing xdebug for PHP 7.1:
  * /usr/local/etc/php/7.1/conf.d/ext-xdebug.ini was created,
    do not forget to remove it upon extension removal.
  * Validate installation via one of the following methods:
  *
  * Using PHP from a webserver:
  * - Restart your webserver.
  * - Write a PHP page that calls "phpinfo();"
  * - Load it in a browser and look for the info on the xdebug module.
  * - If you see it, you have been successful!
  *
  * Using PHP from the command line:
  * - Run `php -i "(command-line 'phpinfo()')"`
  * - Look for the info on the xdebug module.
  * - If you see it, you have been successful!

開(kāi)啟PHP的Xdebug

經(jīng)過(guò)上面步驟,系統(tǒng)里面是有Xdebug了,但是在php.ini配置文件中不一定有,因此需要手動(dòng)添加X(jué)debug的配置項(xiàng):

[xdebug]
zend_extension="/usr/local/opt/php71-xdebug/xdebug.so"
xdebug.remote_enable = 1
xdebug.remote_autostart = 1
xdebug.remote_connect_back = 1
xdebug.remote_port = 9000
xdebug.scream = 0
xdebug.show_local_vars = 1

然后就是重啟php-fpm

# 關(guān)閉php-fpm
sudo killall php-fpm

# 啟動(dòng)php-fpm
sudo php-fpm

運(yùn)行php -i "(command-line 'phpinfo()')" | grep xdebug后,你就可以看到關(guān)于Xdebug的配置內(nèi)容了:

xdebug
...
xdebug.remote_autostart => On => On
xdebug.remote_connect_back => On => On
xdebug.remote_cookie_expire_time => 3600 => 3600
xdebug.remote_enable => On => On
xdebug.remote_handler => dbgp => dbgp
xdebug.remote_host => localhost => localhost
xdebug.remote_log => no value => no value
xdebug.remote_mode => req => req
xdebug.remote_port => 9000 => 9000
xdebug.remote_timeout => 200 => 200
xdebug.scream => Off => Off
...

Visual Studio Code - PHP Debug

VSCode是目前最流行的開(kāi)發(fā)工具之一,雖然輕量,但是對(duì)標(biāo)各類(lèi)IDE毫不遜色,微軟良心之作,通過(guò)安裝不同的插件可以擴(kuò)展它的能力,其中有一款 PHP Debug的插件,可以作為Xdebug的橋梁,方便直接通過(guò)Xdebug調(diào)試PHP,官方的描述十分貼切:

PHP Debug Adapter for Visual Studio Code

官網(wǎng)的指導(dǎo)也寫(xiě)的相當(dāng)不錯(cuò):

  1. Install XDebug
    I highly recommend you make a simple test.php file, put a phpinfo(); statement in there, then copy the output and paste it into the XDebug installation wizard. It will analyze it and give you tailored installation instructions for your environment.
    In short:

    • On Windows: Download the appropiate precompiled DLL for your PHP version, architecture (64/32 Bit), thread safety (TS/NTS) and Visual Studio compiler version and place it in your PHP extension folder.

    • On Linux: Either download the source code as a tarball or clone it with git, then compile it.

  2. Configure PHP to use XDebug by adding zend_extension=path/to/xdebug to your php.ini.
    The path of your php.ini is shown in your phpinfo() output under "Loaded Configuration File".

  3. Enable remote debugging in your php.ini:

    [XDebug]
    xdebug.remote_enable = 1
    xdebug.remote_autostart = 1

    There are other ways to tell XDebug to connect to a remote debugger than remote_autostart, like cookies, query parameters or browser extensions. I recommend remote_autostart because it "just works". There are also a variety of other options, like the port (by default 9000), please see the XDebug documentation on remote debugging for more information.

  4. If you are doing web development, don't forget to restart your webserver to reload the settings

  5. Verify your installation by checking your phpinfo() output for an XDebug section.

這里需要注意的是它推薦開(kāi)啟Xdebug配置項(xiàng)中的remote_autostart這一項(xiàng)。

好了,經(jīng)過(guò)上面的操作,你應(yīng)該可以跟Demo里面一樣在VSCode中調(diào)試PHP了。
macOS PHP7怎么增加X(jué)debug

到此,相信大家對(duì)“macOS PHP7怎么增加X(jué)debug”有了更深的了解,不妨來(lái)實(shí)際操作一番吧!這里是創(chuàng)新互聯(lián)網(wǎng)站,更多相關(guān)內(nèi)容可以進(jìn)入相關(guān)頻道進(jìn)行查詢(xún),關(guān)注我們,繼續(xù)學(xué)習(xí)!


本文題目:macOSPHP7怎么增加X(jué)debug
文章起源:http://fisionsoft.com.cn/article/ishhho.html