In the previous PHP series of the article "PHP Integrated Development Environment Comparison", I based on my own experience, very brief introduction and comparison of several commonly used integrated development environment, personally, compared to Zend Studio and Phpstorm, after asking too much Niang and Google, I found that I could find many versions of the configuration that were introduced under Windows, but little about the configuration information under the MAC, so I decided to write an article myself.
This paper mainly describes the installation and configuration of Phpstorm development environment and XDEBUG debugging environment under MAC, because Phpstorm is not like Zend company for Zend Studio, which integrates many development parts, including interpreter, debugger, virtual machine, server, development framework and so on. 。 Therefore, the configuration of the Phpstorm development environment is relatively cumbersome, there are many areas to be aware of. This article is a very systematic and comprehensive introduction to the configuration of the entire development and debugging environment, designed to be the best Mac on the configuration of the PHP development environment tutorial.
First, download
Phpstorm is the JetBrains company's charge products, but for students and teachers have a free version, in addition, in the celestial, fees are not a thing ...
XAMPP is a free, cross-platform, multi-functional software station collection package that mainly includes the latest Apache, MySQL, PHP, and PERL distributions, which eliminates the hassle of choosing MySQL and PHP's compilation and configuration options, allowing you to focus on programming.
Second, installation
As for the installation, everyone is a programmer, I think this should not need me to repeat ...
Third, the configuration
After installing the Phpstorm will start the first new project, and IntelliJ idea very similar, in fact, the JetBrains family of integrated development environment are highly similar, familiar with one of them, like to open up the two, then learn and use it is very convenient, good, Gossip does not continue to rip ...
1. XAMPP Configuration
1.1> Adding Xdebug Debugger
1) The latest version of XAMPP comes with the xdebug.so module [located in the no-debug-non-zts-20131226 package].
2) Open the Applications/xampp/etc/php.ini configuration file and add the following to the bottom of the section.
[Xdebug]
Zend_extension=/applications/xampp/xamppfiles/lib/php/extensions/no-debug-non-zts-20131226/xdebug.so
Xdebug.remote_autostart=on
Xdebug.remote_enable=on
Xdebug.remote_enable=1
Xdebug.remote_mode= "Req"
Xdebug.remote_log= "/var/log/xdebug.log"
xdebug.remote_host=localhost/127.0.0.1
xdebug.remote_port=9000
Xdebug.remote_handler= "DBGP"
xdebug.idekey= "Phpstorm"
After the 1.2> setup is complete, restart Apache, enter http://localhost/xampp/in the browser to view the phpinfo () information so that the initial configuration of the PHP debugger Xdebug is completed.
2. Phpstorm Configuration
2.1> initialization of the development environment
1) Open Phpstorm->create New project-> Set the default path/applications/xampp/htdocs/(personal advice is set to this default path for XAMPP), and the project name.
2. Create a new. php file and set the line number, right-click to tick.
3) Set the IDE theme, recommended Darcula Diablo series, the eyes for a long time can not feel tired.
4) Set the font and text size, recommended Monaco and Menlo fonts, displayed on the Mac is very beautiful.
5) PHP is an interpreted dynamic language, so the PHP interpreters interpreter must be set [located at. /xampp/bin directory], special note : Due to the phpstorm built-in PHP version, XAMPP PHP version can not be too high, or there will be unrecognized PHP version and Debugger situation.
6) Finally check if PHP's coding style is right for you or your team, PHPDOC provides a standard code comment reference, with a small number of customization options.
2.2> configuration of Xdebug and servers
1) Open File>settings>php>servers, add Web application Debug server.
2) Open File>settings>php>debug to view Xdebug configuration information, where the Debug port is 9000 (actually to see if and in front of the server php.ini Xdebug.remote_por T remain consistent, or set other large ports such as: 10000, as long as they are the same.
3) Open FILE>SETTINGS>PHP>DEBUG>DBGP Proxy, IDE key can be easily filled out as: Phpstorm,host can be set to localhost or 127.0.0.1,port refers to HTTP port, the default is 80, of course, can be arbitrarily modified, the server's HTTP port is set to the same.
3. browser extension configuration
PHP is a powerful WEB development language, if there is no browser for joint debugging is a joke, in general, we recommend the use of Chrome browser and Firefox Browser for development (choose one):
3.1>chrome I recommend JetBrains IDE support plug-in (commonly known as JB Big Plug-in), the official development of plug-in compatibility is naturally very high, do not need to be configured to use directly, do not need to refresh and run to display the content of your code in real time (mainly HTML Markup language), very convenient and highly recommended.
3.2>firefox I recommend the easiest Xdebug plugin, set the IDE key = Phpstorm in the options (that is, as with the IDE key set under DBGP Proxy), and it is not complex to configure.
Fourth, commissioning
Well, the configuration for Xdebug and Phpstorm can now be over, so let's start debugging the test now and see if there's a problem with the configuration above.
1) Activate the "Start Listen for PHP debug Connections" button of the Phpstorm IDE (the phone-like icon in the upper-right corner of the debug area, with a red-forbidden small circle flag indicating inactive, green indicates listening).
2) Set breakpoints.
3) Click the Crawler button to start the debug state.
4) The browser will start the window waiting for debugging sessions, press F7 to do the breakpoint debugging, no need to echo or print such cumbersome printing debugging.
fifth. Summary
1) port number settings must be the same, such as: Xdebug Port, HTTP port.
2) The IDE Key setting must also be the same.
3) One thing I did not know, is phpstorm in the debug mode of the generated files (in the/bin/debug virtual directory), always prompt to do path mappings, but in fact the project source files in the root directory of the WEB, non-remote debug mode Do not need to do path mappings, I do not know what the reason has been warning, very uncomfortable.
4) about the use of Phpstorm shortcut keys, GIT/SVN version control, configuration FTP service and so on using the skills, because the current Bo each series of articles just starting, is desperately writing, perhaps a future day to consider writing a full guide to the tutorial, first see how the response to this article.
Mac+phpstorm+xampp+xdebug