WIN8.1下搭建PHP5.6环境_PHP
第一次接触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 ;如果设得太小,函数中有递归调用自身次数太多时会报超过最大嵌套数错
②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页面
运行结果:
结果运行正确,到此本篇文章也就结束了,希望能对观者有所帮助。
以上所述就是本文的全部内容了,希望大家能够喜欢。

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

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

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics











There are four main error types in PHP: 1.Notice: the slightest, will not interrupt the program, such as accessing undefined variables; 2. Warning: serious than Notice, will not terminate the program, such as containing no files; 3. FatalError: the most serious, will terminate the program, such as calling no function; 4. ParseError: syntax error, will prevent the program from being executed, such as forgetting to add the end tag.

In PHP, password_hash and password_verify functions should be used to implement secure password hashing, and MD5 or SHA1 should not be used. 1) password_hash generates a hash containing salt values to enhance security. 2) Password_verify verify password and ensure security by comparing hash values. 3) MD5 and SHA1 are vulnerable and lack salt values, and are not suitable for modern password security.

PHP and Python each have their own advantages, and choose according to project requirements. 1.PHP is suitable for web development, especially for rapid development and maintenance of websites. 2. Python is suitable for data science, machine learning and artificial intelligence, with concise syntax and suitable for beginners.

PHP is widely used in e-commerce, content management systems and API development. 1) E-commerce: used for shopping cart function and payment processing. 2) Content management system: used for dynamic content generation and user management. 3) API development: used for RESTful API development and API security. Through performance optimization and best practices, the efficiency and maintainability of PHP applications are improved.

HTTP request methods include GET, POST, PUT and DELETE, which are used to obtain, submit, update and delete resources respectively. 1. The GET method is used to obtain resources and is suitable for read operations. 2. The POST method is used to submit data and is often used to create new resources. 3. The PUT method is used to update resources and is suitable for complete updates. 4. The DELETE method is used to delete resources and is suitable for deletion operations.

PHP is a scripting language widely used on the server side, especially suitable for web development. 1.PHP can embed HTML, process HTTP requests and responses, and supports a variety of databases. 2.PHP is used to generate dynamic web content, process form data, access databases, etc., with strong community support and open source resources. 3. PHP is an interpreted language, and the execution process includes lexical analysis, grammatical analysis, compilation and execution. 4.PHP can be combined with MySQL for advanced applications such as user registration systems. 5. When debugging PHP, you can use functions such as error_reporting() and var_dump(). 6. Optimize PHP code to use caching mechanisms, optimize database queries and use built-in functions. 7

In PHPOOP, self:: refers to the current class, parent:: refers to the parent class, static:: is used for late static binding. 1.self:: is used for static method and constant calls, but does not support late static binding. 2.parent:: is used for subclasses to call parent class methods, and private methods cannot be accessed. 3.static:: supports late static binding, suitable for inheritance and polymorphism, but may affect the readability of the code.

PHP handles file uploads through the $\_FILES variable. The methods to ensure security include: 1. Check upload errors, 2. Verify file type and size, 3. Prevent file overwriting, 4. Move files to a permanent storage location.
