Construction of PHP development and debugging environment under MAC environment

Construction of PHP development and debugging environment under MAC environment

background

A friend asked me to do something small and needed to use server-side technology. After selection, PHP language was used as the server-side language for development. The following summarizes the construction process of the PHP environment, which mainly involves the following:

  • MAMP installation configuration
    • Create and configure servers
    • XDebug configuration
  • PHPStorm installation configuration
    • Set up the PHP parser
    • Set up the PHP debugger
    • Set up PHPServer
    • run and debug

MAMP installation configuration

Download address
https://pan.baidu.com/s/1osN7QFWjAfE2HsUIGZKJ3Q
Password: xclient.info

Create and configure servers

1. Select hosts settings and click the plus button in the lower right cornerSelect hosts settings and click the plus button in the lower right corner

2. Fill in the server address and Document root. Document root is the path of the php project. Generally, it is the root directory of the project.
Fill in the server address and Document root
 3. More Host settings
via /etc/host file Remember to select the checkbox in this place, in fact, it is Add configuration in /etc/hosts file

127.0.0.1	phplearningloc	# MAMP PRO - Do NOT remove this entry!
::1		phplearningloc	# MAMP PRO - Do NOT remove this entry!

In this way, the server can be accessed using the phplearningloc domain name address
.More Host settings

4. Port set
the Apache server port to 80 ,
MySQL port to 3306,
click the set button, and finally save to restart the
server.Port settings

XDebug configuration

XDebug is a debugging tool for PHP. PHPStorm also needs to be configured later to debug code breakpoints. First configure XDebug in MAMP, and then use the configuration of XDebug in MAMP in PHPStorm.
1. First, XDebug (Debugger ) This checkbox needs to be checked
The XDebug (Debugger) checkbox needs to be checked

2. Then click the small arrow next to Manually enable other extensions to modify the configuration
Modify the configuration filefile

[xdebug]
MAMP_Xdebug_MAMPzend_extension="/Applications/MAMP/bin/php/php5.6.32/lib/php/extensions/no-debug-non-zts-20131226/xdebug.so"
 xdebug.remote_enable=1
 xdebug.remote_host=localhost
 xdebug.remote_port=9010
 xdebug.remote_autostart=1
 xdebug.profiler_enable=0
 xdebug.remote_handler=dbgp
 xdebug.idekey="PHPSTORM"
 ;xdebug.profiler_output_dir="/Applications/MAMP/tmp"

There are two places in this paragraph that need to be configured the same in PHPStorm xdebug.idekey="PHPSTORM"and xdebug.remote_port=9010, the values ​​here can be customized

After setting, save and close

PHPStorm installation configuration

After PHPStorm is installed, create a new test project, and then need to configure it for this project

Set up the PHP parser

Configuration path: Preference->Languages ​​& Frameworks -> PHP
Set up the PHP parser

Select the location of the PHP executable file. Below I use the PHP5.6 version pre-installed by MAMP. After the selection is complete, click OK.

Select the location of the PHP executable

Set up the PHP debugger

Configuration path: Preference->Languages ​​& Frameworks -> PHP -> Debug
Debug Port Location Fill in the port configured in the [XDebug Configuration] section: 9010

Fill in the Debug Port location

DBGp Proxy configuration
Configuration path: Preference->Languages ​​& Frameworks -> PHP -> Debug -> DBGp Proxy
IDE key Fill in the key configured in the [XDebug Configuration] section: PHPSTORM
Port Fill in the port configured in the [XDebug Configuration] section: 9010
host Fill in the server name configured in the [New and Configure Server] section: phplearningloc

DBGp Proxy configuration

Skipped Paths configuration
In addition, you need to filter the default projects that come with MAMP to prevent opening these projects from entering breakpoints in PHPStorm

Skipped Paths Configuration

Finally, verify the configuration, open the monitor, a small phone button will turn green, and then click validate

Finally verify the configuration

Select the project path to be verified and the corresponding server
addressSelect the project path to be verified and the corresponding server address

After verification, the following information will be displayed:
Verified

Set up PHPServer

Configuration path: Preference->Languages ​​& Frameworks -> PHP -> Server
Port Fill in the port configured in the [New and Configure Server] section: 80
Host Fill in the server name configured in the [New and Configure Server] section: phplearningloc (size-insensitive Write)
Name can be written arbitrarily, which will be used in the subsequent configuration of the running environment

Set up PHPServer

PHP project running environment configuration

PHP project running environment configuration
 Select Edit Configuration

Select Edit Configuration
 Click Add to create a new PHP Web Page project operating environment
 Click Add to create a new PHP Web Page project runtime environment

Click Add to create a new PHP Web Page project runtime environment

The PHP Web Page configuration is as follows:
Server is the Server
Start URL configured in the previous step. Here, the root path set to the project is "/"
Browser Set debugging, run the opened browserPHP Web Page Configuration

run and debug

First of all, make sure that the monitored small phone button is in the green state, and then the debug button of the store's little bug, hit a breakpoint in the code as follows:
run and debug

The line entering the breakpoint will be highlighted, and the Debug control panel will display the debugging information as followsThe line entering the breakpoint is highlighted

The function buttons of the debugging panel are explained as follows:

The function buttons of the debugging panel are explained as follows

Summarize

The above is the construction of the MAMP+PHPStorm development environment. If there is something wrong, please let me know.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326079231&siteId=291194637