前言:php
一、本身摸索安装git
二、快速安装github
安装这个扩展是因为Zephir 编译不能始终经过,无可奈何啊,使用Zephir写扩展,老是出现如下错误:web
www@ubuntu1:~/phalcon-zephir/$ sudo zephir build Segmentation fault (core dumped)
去官方问问,因为php cli 没有安装 Disable xdebug 扩展致使的结果thinkphp
开始安装json
git clone git://github.com/xdebug/xdebug.git cd xdebug # 生成configure 配置文件/xdebug$ /opt/php7.0.22/bin/phpize # 查找 php-config 配置我文件 /xdebug$ sudo find / -name php-config /opt/php7.0.22/bin/php-config # 配置 ./configure --enable-xdebug --with-php-config=/opt/php7.0.22/bin/php-config # 编译 make -j2
# 安装
sudo make install
编译成功后的界面ubuntu
cli 添加配置文件,是如下红色部分:vim
vim /etc/php/7.0/cli/php.ini 添加如下代码:浏览器
zend_extension=/opt/php7.0.22/lib/php/extensions/no-debug-non-zts-20151012/xdebug.so
web 页面配置文件bash
sudo vim /opt/php7.0.22/etc/php.ini 配置文件添加
zend_extension=/opt/php7.0.22/lib/php/extensions/no-debug-non-zts-20151012/xdebug.so
重启php-fpm 后的效果
》》》》》》》遇到的坑,如何解决
PHP Fatal error: Class 'jsonserializable' not found in Unknown on line 0
Phalcon 官方:https://github.com/phalcon/zephir/issues/1127
也就是说php cli 命令行的Phalcon扩展没有安装
我是如何作的:
cd /etc/php/7.0/mods-available sudo vim phalcon.ini 添加内容: extension=phalcon.so cd /etc/php/7.0/cli/conf.d/
sudo ln -s /etc/php/7.0/mods-available/phalcon.ini 50-phalcon.ini
一、xdebug 网址 :https://xdebug.org/
二、下载配置安装和本身服务对应的xdebug版本
三、打印本身服务器配置的环境信息(phpinfo()),图小所示
四、鼠标右键查看(phpinfo())网页的源代码,复制全部网页源代码粘贴到(https://xdebug.org/wizard.php)表单输入框中,直接运行便可
五、https://xdebug.org/wizard.php 页面将会出现与之对应的xdebug 配置信息
(1)Linux 配置信息
Tailored Installation Instructions
Summary
Xdebug installed: 2.6.0alpha1
Server API: FPM/FastCGI
Windows: no
Zend Server: no
PHP Version: 7.1.9
Zend API nr: 320160303
PHP API nr: 20160303
Debug Build: no
Thread Safe Build: no
Configuration File Path: /usr/local/php-7.1.8/etc
Configuration File: /usr/local/php-7.1.8/etc/php.ini
Extensions directory: /usr/local/php-7.1.8/lib/php/extensions/no-debug-non-zts-20160303
Instructions
Download xdebug-2.6.0.tgz
Unpack the downloaded file with tar -xvzf xdebug-2.6.0.tgz
Run: cd xdebug-2.6.0
Run: phpize (See the FAQ if you don't have phpize.
As part of its output it should show:
Configuring for:
...
Zend Module Api No: 20160303
Zend Extension Api No: 320160303
If it does not, you are using the wrong phpize. Please follow this FAQ entry and skip the next step.
Run: ./configure
Run: make
Run: cp modules/xdebug.so /usr/local/php-7.1.8/lib/php/extensions/no-debug-non-zts-20160303
Update /usr/local/php-7.1.8/etc/php.ini and change the line
zend_extension = /usr/local/php-7.1.8/lib/php/extensions/no-debug-non-zts-20160303/xdebug.so
Restart the webserver
If you like Xdebug, and thinks it saves you time and money, please have a look at the donation page.
(2)Windows 环境配置信息(php-study集成环境)
(3)修改配置文件
[xdebug]
zend_extension = E:\phpStudy\PHPTutorial\php\php-7.1.13-nts\ext\php_xdebug-2.6.0-7.1-vc14-nts.dll
xdebug.remote_enable=1
xdebug.remote_handler=dbgp
xdebug.remote_mode=req
xdebug.remote_host=localhost
xdebug.remote_port=9000
xdebug.idekey="PHPSTORM"
六、按照以上说明下载(或者编译相应的扩展到系统环境中去,记住要修改配置文件后,记得重启服务,验证是否安装成功,出现如下界面表示安装成功
七、 phpstrom 如何配置
(1)打开phpstrom IDE 软件,点击下拉小箭头
(2)添加应用程序 PHP Web Application
(3)配置server 服务器
(4)配置一个本地服务器为了调试
(1)下面咱们经过PHP异常的代码进行测试xDebug
当异常被抛出时,其后的代码不会继续执行,PHP 会尝试查找匹配的 "catch" 代码块。
若是异常没有被捕获,并且又没用使用 set_exception_handler() 做相应的处理的话,那么将发生一个严重的错误(致命错误),而且输出 "Uncaught Exception" (未捕获异常)的错误消息。
让咱们尝试抛出一个异常,同时不去捕获它:
<?php
//create function with an exception
function checkNum($number)
{
$res = $number;
if ($res > 10) {
throw new Exception("Value must be 1 or below");
}
return true;
}
//trigger exception
checkNum(2);
(2)演示效果
【1】配置phpStrom的Xdebug配置
【2】使用一个PHP异常的代码做为调试
【3】调制以前一开启监听Xdebug
【4】在须要调试的行上打上断点(点击一下行号后面的空白处便可,再点一次取消断点),如下咱们打了两个断点
【5】开始调试,记得必定要打断点
【6】这时候会自动打开浏览器你所要调试的URL地址,同时携带xDebug的ID(http://localhost/Xdebug-Test/index.php?XDEBUG_SESSION_START=10409)
【7】这时候phpStrom IDE 会自动转向调试的代码片断(若是你是刷新的,则会在任务栏提示你,一闪一闪的),也就打断点的地方
注意:以上的断点和刚开始打的断点已经不一样的,中间是一个(√)对号,表示调试已经开始了
【8】按住F8进行调试,Variables 部分中的数据为Xdebug输出的数据 $number = 2
F8 继续调试,能够看出当前的值$res = 2,能够看出传入的参数,还有那个当前变量的值是多少一目了然
重复以上步骤,给 checkNum() 函数传递不一样的参数,经过Xdebug查看程序执行的详细步骤,亲自动手试试吧!
【9】根据断点配置,或在打开 Debug URL 的过程当中,或在 POST 以后,若是 PhpStorm 监听到了 Debug 链接,就会当即切换到编辑器界面,并跳转到设置的断点处,浏览器端会等待 PhpStorm 的操做。
【10】以上为本地最简单的调试就此结束
一、测试环境:
(1)运行环境:phpStudy 集成环境
(2)框架:使用TP5 最新框架测试
二、下载框架
TP5.1 只能使用composer安装,安装详细地址:https://www.kancloud.cn/manual/thinkphp5_1/353948
安装命令:composer create-project topthink/think tp5.1
三、浏览器查看是否安装成功
四、配置域名
五、phpStrom 配置
修改配置文件:php.ini
[XDebug] xdebug.profiler_output_dir="E:\phpStudy\PHPTutorial\tmp\xdebug" xdebug.trace_output_dir="E:\phpStudy\PHPTutorial\tmp\xdebug" zend_extension = E:\phpStudy\PHPTutorial\php\php-7.1.13-nts\ext\php_xdebug-2.6.0-7.1-vc14-nts.dll xdebug.remote_enable=1 xdebug.remote_handler=dbgp xdebug.remote_mode=req xdebug.remote_host=tp5.test xdebug.remote_port=9000 xdebug.remote_connect_back=1 xdebug.remote_autostart=1
若是 xdebug.remote_host = 127.0.0.1 则验证未经过,因此必须设置为域名(上面配置的tp5.test)
验证经过
开始调试。提示错误信息
解决办法,项目目录作一个映射既能够
补充:若是是本地调试的话,要作一个映射的
继续调试,则和第一次配置localhost同样调试就能够了
自动配置命名空间
配置完成以后
咱们再次新建项目的时候,命名空间已经自动加载上了(固然了,若是该文件夹下面已经建立过一次文件了,则第二次建立的时候也会自动提示命名空间的)