Home Backend Development PHP Tutorial WIN8.1下搭建PHP5.6环境_PHP

WIN8.1下搭建PHP5.6环境_PHP

Jun 01, 2016 am 11:06 AM
win8.1

  第一次接触php是在2014-5月份左右,当时是自己的主攻方向是C#,对php比较排斥, 其中很多一部分原因,就是PHP的断点调试一直无法配置成功,用echo打印日志的方式排错,使得自己对php心生怨恨,而错失了深入学习php的好机会。这次写这篇随笔,一方面是记录自己php方向的起航,另一方面也是希望能帮助刚接触php的初学者么,能够顺利的配置php的环境,而不至于对php产生恐惧。

一、系统环境简介

  Windows系统是一个非常常见的系统。相信这里也不用多做解释。那么如何开启IIS(win8.1),其实网上已经有很多教程,我这里只做简单的介绍。

  ①安装.net fromework 3.5

  IIS运行需要依赖.net3.5,因此第一步就是安装.net fromework3.5。安装方法大致有两种,一种是在线下载,速度非常慢(真的非常慢),这里给大家介绍第二种,离线安装.net fromework3.5。找到安装win8的iso文件,加载到虚拟光驱中,如果有刻U盘系统的插入U盘即可。运行 “命令提示符(管理员)”(右键桌面的Win图标),输入命令“dism.exe /online /enable-feature /featurename:NetFX3 /Source:V:\sources\sxs”,V盘表示虚拟光驱的盘符或U盘的盘符。

  ②开启IIS

  做开发的,开启IIS应该是小case了。这里就不多说了。

二、预先工作

  ①环境及IDE等文件下载

  以下为参考网址,如无法打开或变动,请自行搜索,获取最新版本文件请行搜索,以下链接版本日期:2015-4-29最新

  PHPManager:http://www.iis.net/downloads/community/2010/09/php-manager-for-iis-7

  PHP:http://windows.php.net/download

  XDebug:http://xdebug.org/

  PHPStrom:http://www.jetbrains.com/phpstorm/

  Xdebug Helper:http://www.chromein.com/crx_11294.html

  ②安装

  初始的IIS是不支持php的,所以我们先下载了PHP Manager这个工具,安装成功后,可以在IIS中看到php manager的图标,如下图:

进入php manager。后续配置比较简单,请自行百度,本文文的重点是讲断点调试,所以就不多啰嗦了。php配置完成后会看到如下界面:

将下载下来xdebug的解压文件复制到php目录的ext文件夹中

接下来就是IDE的安装了,PHPStorm安装还是很简单的,这里也不做多说,Xdebug helper是Chrome的一个扩展工具,在浏览器中输入chrome://extensions/,然后将下载下来的crx文件拖入该页面就可以了。

三、配置

  ①Xdebug

  Xdebug的配置网上一搜一大片,这里只给出我的配置,在php.ini文件中,加入以下代码,注意其中几个文件的位置。  

[Xdebug] ;xdebug配置
zend_extension="D:/php/php-5.6.8-nts-Win32-VC11-x64/ext/php_xdebug-2.3.2-5.6-vc11-nts-x86_64.dll" ;载入Xdebug
xdebug.idekey="PHPSTORM"
xdebug.profiler_enable=on
xdebug.trace_output_dir="D:/php/xdebug-log" ;xdebug 的数据文件目录
xdebug.profiler_output_dir="D:/php/xdebug-log" ;xdebug 的数据文件目录
xdebug.auto_trace = On ;开启自动跟踪
xdebug.show_exception_trace = On ;开启异常跟踪
xdebug.remote_autostart = Off ;开启远程调试自动启动
xdebug.remote_enable = On ;开启远程调试
xdebug.remote_handler=dbgp ;用于zend studio远程调试的应用层通信协议
xdebug.remote_host=localhost ;允许连接的zend studio的IP地址
xdebug.remote_port=9001 ;反向连接zend studio使用的端口
xdebug.collect_vars = On ;收集变量
xdebug.collect_return = On ;收集返回值
xdebug.collect_params = On ;收集参数
xdebugbug.max_nesting_level = 10000 ;如果设得太小,函数中有递归调用自身次数太多时会报超过最大嵌套数错
Copy after login

  ②PHPStorm

  进入php设置

  

   选择php语言设置

添加解释器,其实如果你在IIS中运行,是不用添加解释器的,不过如果直接通过phpstorm来打开你的php代码则需要添加解释器,如下,按Alt+F2。通过解释器运行php,是不需要安装IIS的

接下来就是配置phpStorm的debug了。其实phpstorm的debug基本都有默认设置了,但我们最好还是要修改一下,因为可能9000端口被其他应用占用了。所以我们需要更改为其他端口,例如9001

注意:这里的端口要与php.ini中xdebug中的端口配置一致,请看上面的配置代码。

xdebug.remote_port=9001 ;反向连接zend studio使用的端口

 ③xdebug helper

它是Chrome的一个插件,真的很好用,配置很简单,直接上图


到这配置基本结束了。下面我们测试一下。

四、断点调试测试

  ①找到页面,开启调试,点击小虫,选择Debug。



②PHPstorm开启监听


刷新http://localhost/php/FirstPHP.php页面



运行结果:


结果运行正确,到此本篇文章也就结束了,希望能对观者有所帮助。

以上所述就是本文的全部内容了,希望大家能够喜欢。

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Explain JSON Web Tokens (JWT) and their use case in PHP APIs. Explain JSON Web Tokens (JWT) and their use case in PHP APIs. Apr 05, 2025 am 12:04 AM

JWT is an open standard based on JSON, used to securely transmit information between parties, mainly for identity authentication and information exchange. 1. JWT consists of three parts: Header, Payload and Signature. 2. The working principle of JWT includes three steps: generating JWT, verifying JWT and parsing Payload. 3. When using JWT for authentication in PHP, JWT can be generated and verified, and user role and permission information can be included in advanced usage. 4. Common errors include signature verification failure, token expiration, and payload oversized. Debugging skills include using debugging tools and logging. 5. Performance optimization and best practices include using appropriate signature algorithms, setting validity periods reasonably,

Describe the SOLID principles and how they apply to PHP development. Describe the SOLID principles and how they apply to PHP development. Apr 03, 2025 am 12:04 AM

The application of SOLID principle in PHP development includes: 1. Single responsibility principle (SRP): Each class is responsible for only one function. 2. Open and close principle (OCP): Changes are achieved through extension rather than modification. 3. Lisch's Substitution Principle (LSP): Subclasses can replace base classes without affecting program accuracy. 4. Interface isolation principle (ISP): Use fine-grained interfaces to avoid dependencies and unused methods. 5. Dependency inversion principle (DIP): High and low-level modules rely on abstraction and are implemented through dependency injection.

How to automatically set permissions of unixsocket after system restart? How to automatically set permissions of unixsocket after system restart? Mar 31, 2025 pm 11:54 PM

How to automatically set the permissions of unixsocket after the system restarts. Every time the system restarts, we need to execute the following command to modify the permissions of unixsocket: sudo...

How to debug CLI mode in PHPStorm? How to debug CLI mode in PHPStorm? Apr 01, 2025 pm 02:57 PM

How to debug CLI mode in PHPStorm? When developing with PHPStorm, sometimes we need to debug PHP in command line interface (CLI) mode...

Explain the concept of late static binding in PHP. Explain the concept of late static binding in PHP. Mar 21, 2025 pm 01:33 PM

Article discusses late static binding (LSB) in PHP, introduced in PHP 5.3, allowing runtime resolution of static method calls for more flexible inheritance.Main issue: LSB vs. traditional polymorphism; LSB's practical applications and potential perfo

How to send a POST request containing JSON data using PHP's cURL library? How to send a POST request containing JSON data using PHP's cURL library? Apr 01, 2025 pm 03:12 PM

Sending JSON data using PHP's cURL library In PHP development, it is often necessary to interact with external APIs. One of the common ways is to use cURL library to send POST�...

Explain late static binding in PHP (static::). Explain late static binding in PHP (static::). Apr 03, 2025 am 12:04 AM

Static binding (static::) implements late static binding (LSB) in PHP, allowing calling classes to be referenced in static contexts rather than defining classes. 1) The parsing process is performed at runtime, 2) Look up the call class in the inheritance relationship, 3) It may bring performance overhead.

See all articles