Prepare EclipsePHP development environment

Source: Internet
Author: User
Tags php server php debugger php development environment php web server
Set up EclipsePHP development environment to build a PHP development environment: & nbsp; 1. prepare and install the following software: & nbsp; MySQL5.1.30: http://dev.mysql.com/down build Eclipse PHP development environment
Build a PHP development environment:
1. prepare and install the following software:
MySQL 5.1.30: http://dev.mysql.com/downloads /.
Apache 2.2.14: http://httpd.apache.org/. three text boxes appear during installation, the above two enter your local IP (for example: 127.0.0.1), enter your EMAIL at the bottom. After the installation is complete, apache is automatically started to test whether apache is started successfully. Enter http: // localhost/or http: // 127.0.0.1 in the address bar of the browser. if "It works. ", congratulations, apache has been successfully installed. at the same time, there is a green apache server running icon in the taskbar in the lower right corner of the computer.
PHP 5.2.11: http://www.php.net/downloads.php. download a zip package that does not need to be installed. do not use the installer package. (if this is used, many php extensions are not installed, such as the mysql extension of php, as a result, the mysql database cannot be connected ).
Zend Debugger 5.2: http://www.zend.com/en/products/studio/downloads. select Studio Web Debugger.
Eclipse for PHP: http://www.eclipse.org/downloads/. Note that it is the version of Galileo Packages based on Eclipse 3.5 sr1. Eclipse's workspace is set to D:/php_workspace.
After installation, make some basic configurations for Eclipse. If you want to make the development of applications have better international support, to maximize support for Chinese output, it is best to use UTF-8 encoding.
However, the default character encoding of the Eclipse workspace is the default encoding of the operating system. the default encoding of the simplified Chinese operating system (Windows XP, Windows 2000 simplified Chinese) is GBK or GB18030, the project code created in this workspace is GBK or GB18030, and the text files created in the project are also GBK or GB18030. If you want to make a new project, file to make UTF-8 directly, you need to do the following:
Open Window-> Preferences-> General-> Workspace, set "Thext file encodiing" to a UTF-8, and the Text file encoding in its properties dialog box will be a UTF-8.
Modify the encoding of various files: in Window-> Preferences-> General-> Content Type, there are various file formats under Text. select the corresponding file format, in the Default encoding input box below
Enter the UTF-8 and click Update. For PHP development, it is best to set HTML and PHP file encoding as UTF-8.
2. load apache into the php module: conf/httpd. conf. add the following content at the end to load the php module. ensure that the version is consistent.
PHPIniDir "D:/PHP/"  LoadModule php5_module "D:/PHP/php5apache2_2.dll"  AddType application/x-httpd-php .php

Note that if your apache version is 2.0, enter LoadModule php5_module "D:/php/php5apache2. dll ".
3. add the virtual directory and default homepage: the default site home directory is Apache's htdocs directory. To place all Eclipse projects under D:/php_workspace, you need to create a virtual directory pointing to the directory where the eclipse project is located to access the php files under each project. Modify httpd. conf and add the following content at the end of the file:
Alias /Workspace/ "D:/php_workspace/"  
 
       Options Indexes MultiViews     AllowOverride None     Order allow,deny     Allow from all  
 

The advantage of this is that all php projects share an apache configuration, and you can access the php file under the corresponding project through http: // localhost/Workspace/ProjectDirectory.
4. PHP configuration:
(1) rename php. ini-recommended under D:/php to php. ini.
(2) set the following items:
Zend. ze1_compatibility_mode = Off // whether PHP4 is supported. you 'd better disable it, otherwise, an error occurs when you use PHP5 to process Zip files. post_max_size = 20 M // The maximum size of POST information. magic_quotes_gpc = Off // whether to use magic quotes extension_dir = "D: /PHP/ext "// PHP extension upload_max_filesize = 20 M // upload file size max_execution_time = 6000 // maximum page execution time (seconds) max_input_time = 600 // script parsing time limit (seconds) memory_limit = 20 M // maximum memory allocated by the script output_buffering = On // whether to enable the output buffer implicit_flush = On // timely output the buffer content

(3) enable error message: to make debugging easier during development, enable the display_errors and display_startup_errors variables in php. ini. The display_errors variable has an obvious purpose,
It tells PHP whether an error is displayed. In addition, the default value of the variable error_reporting is E_ALL. This setting displays all information from poor coding practices to harmless prompts to errors. E_ALL is a little too detailed for the development process,
Because it displays a prompt on the screen for some trivial matters (such as the variable is not initialized), it will mess up the browser output. If you only want to see errors and bad code practices, but do not want to see harmless prompts, you can set it to the following values:
error_reporting = E_ALL & ~E_NOTICE

(The following configuration is optional) depends on what Apache is doing. opening an error report in PHP may not work because multiple PHP versions may exist on the computer. Sometimes it is difficult to tell which PHP version Apache is using, because Apache can only view one php. ini file. I don't know which php. ini file Apache is using to configure itself as a security issue. However, there is a way to configure the PHP variable in Apache to ensure that the correct error level is set. In addition, it is better to know how to set these configuration variables on the server side to reject or preemptible the php. ini file to provide higher-level security. To add the following lines to the httpd. conf file to overwrite any php. ini file:
php_flag  display_errors        on  php_value error_reporting       2039  

This overwrites the flag set for display_errors and the value of error_reporting in the php. ini file. The value 2039 represents E_ALL &~ E_NOTICE. If you want to use E_ALL, set the value to 2047.
Similarly, restart Apache.
(4) Find the Dynamic Extensions item. here is the PHP extension settings section. enable the following common Extensions (remove the previous ";").
Extension = php_bz2.dll extension = php_curl.dll extension = extend extension = php_dbase.dll extension = php_gd2.dll extension = extend extension = extension // PDO extension = php_pdo_mysql.dll // PDO_MySQL extension = php_sockets.dll extension = php_xmlrpc.dll extension = php_xsl.dll extension = php_zip.dll

(5) decompress Zend Debugger, copy ZendDebugger. dll corresponding to the PHP version to the PHP installation directory, modify php. ini, and add the following content:
[zend]  zend_extension_ts=D:/PHP/ZendDebugger.dll    zend_debugger.allow_hosts=127.0.0.1    zend_debugger.expose_remotely=always 

Decompress the extracted dummy. put php in the httpd DocumentRoot directory and D:/php_workspace/to Test whether the Debugger is connected in Eclipse (Debug deployments-> PHP Web Page-> Test Debugger ),
A success message is displayed. (By modifying the corresponding site directory of worksapce, Configure "Default PHP Web Server" can also be placed under the subdirectory of the website ).
(6) This step is not necessary: to prevent future problems, put the php5ts under PHP. dll, libmysql. dll, and ext/php_mysql.dll, ext/php_mysqli.dll (if this extension is used) three files are copied to Windows/system32.
Note that there are many problems that are hard to solve without code, and the reason for the failure to properly load the extension is (even if the extension_dir in php. ini points to the ext directory ).
It is because the PHP module is loaded by Apache, which is two different software and may often encounter some collaboration problems. In this case, you need to copy the extension you used from ext to system32.
5. configure Eclipse to point to the PHP module: open the Window of Eclipse> Preferences> PHP Executables> Add to Add
Name: PHP 5.2.11
Executable Path: D:/PHP/php.exe
PHP ini file (optional): D:/PHP/php. ini
PHP debugger: Zend Debugger
6. configure the PHP file access URL in Eclipse: Open Window> Preferences> PHP Server, edit the Default PHP Web Server entry, and change the URL to http: // localhost/Workspace, note that the Workspace is added to the URL bar,
This is the directory alias added in httpd. conf.
7. test: restart apache After configuration, and create a new PHP Project named FirstPHPTest. of course, we use D:/php_workspace as the Eclipse workspace directory. Create in project
PHP File, such as phpinfo. php. Content is
   

Right-click phpinfo. php and choose Run As> PHP Web Page.

Reprinted from http://blog.csdn.net/zhoudaxia/article/details/5271250

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.