笔记:MAC OS X下配置PHP开发、调试环境
操作系统:MAC OS X
工具:MAMP、PhpStorm、xdebug、chrome
1、下载MAMP
2、安装比较简单,安装完成后,应用程序中会增加如下4个应用
MacGDBp是PHP调试器,使用的是xdebug
若要使用此调试器,需要在php.ini中配置:
<span style="color: #000000;">[xdebug] zend_extension</span>="/Applications/MAMP/bin/php/php5.5.10/lib/php/extensions/no-debug-non-zts-20121212/xdebug.so"<span style="color: #000000;"> xdebug</span>.remote_enable=1<span style="color: #000000;"> xdebug</span>.remote_host=<span style="color: #000000;">localhost xdebug</span>.remote_port=9000<span style="color: #000000;"> xdebug</span>.remote_autostart=1
zend_extension要根据自己使用的php具体版本和路径设置。
xdebug.remote_port端口要与MacGDBp的Preferences中设置的端口一致。
按上面两步配置完成后,打开MacGDBp,浏览器输入php站点地址,在执行第一行php代码时自动进入调试状态,即在第一行php代码自动加载断点。
MAMP用于启动Apache和MySql服务,如下图所示:
点击Start Servers会启动Apache 和 MySql服务,如下图所示:
点击Open start page可以打开管理界面,用于查看phpInfo以及phpMyAdmin管理MySQL等工具。
点击Preferences,可以配置Apache和MySql的端口,以及PHP版本等信息。
3、MySQLWorkbench和Sequel Pro都是MySql的管理工具,可根据实际情况使用。
4、下载并安装phpStorm,我安装的是7.1.3版本。
5、在php.ini中[xdebug]增加如下一行,xdebug.idekey的值可随意设置,我设置的是PHPSTORM。
xdebug.idekey="PHPSTORM"
6、打开PhpStorm的Preferences,找到PHP下的Debug,配置debug port为上面第2步php.ini中设置的端口9000,其他按默认设置即可。
7、浏览器配置,Chrome浏览器安装Xdebug helper
安装好后,点击Chrome的[设置]菜单,点击[扩展程序]
再点击Xdebug helper的选项
设置IDE Key,在下拉列表中选择Other,输入PHPSTORM(也就是我们在前面步骤中的php.ini中设置的xdebug.idekey),输入完成后,点击保存图标即可。
我们也可以直接在下拉列表中选择PhpStorm。
8、调试程序
点击PhpStorm的菜单 Run -> Start Listen PHP Debug Connections 开启监听
在PhpStom开发环境中,在php某行代码处设置断点
Chrome浏览器中输入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











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.

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.

PHP is still dynamic and still occupies an important position in the field of modern programming. 1) PHP's simplicity and powerful community support make it widely used in web development; 2) Its flexibility and stability make it outstanding in handling web forms, database operations and file processing; 3) PHP is constantly evolving and optimizing, suitable for beginners and experienced developers.

JavaScript is the cornerstone of modern web development, and its main functions include event-driven programming, dynamic content generation and asynchronous programming. 1) Event-driven programming allows web pages to change dynamically according to user operations. 2) Dynamic content generation allows page content to be adjusted according to conditions. 3) Asynchronous programming ensures that the user interface is not blocked. JavaScript is widely used in web interaction, single-page application and server-side development, greatly improving the flexibility of user experience and cross-platform development.

C is an ideal language for beginners to learn programming, and its advantages include efficiency, versatility, and portability. Learning C language requires: Installing a C compiler (such as MinGW or Cygwin) Understanding variables, data types, conditional statements and loop statements Writing the first program containing the main function and printf() function Practicing through practical cases (such as calculating averages) C language knowledge

Pythonempowersbeginnersinproblem-solving.Itsuser-friendlysyntax,extensivelibrary,andfeaturessuchasvariables,conditionalstatements,andloopsenableefficientcodedevelopment.Frommanagingdatatocontrollingprogramflowandperformingrepetitivetasks,Pythonprovid

Python is an ideal programming introduction language for beginners through its ease of learning and powerful features. Its basics include: Variables: used to store data (numbers, strings, lists, etc.). Data type: Defines the type of data in the variable (integer, floating point, etc.). Operators: used for mathematical operations and comparisons. Control flow: Control the flow of code execution (conditional statements, loops).

Getting Started with Python Programming Install Python: Download and install from the official website. HelloWorld!: Use print("HelloWorld!") to print the first line of code. Practical case: Calculate the area of a circle: Use π (3.14159) and the radius to calculate the area of the circle. Variables and data types: Use variables to store data. Data types in Python include integers, floating point numbers, strings, and Boolean values. Expressions and assignments: Use operators to connect variables, constants, and functions, and use the assignment operator (=) to assign values to variables. Control flow: if-else statement: execute different code blocks based on conditions, determine odd
