Preparing the Eclipse PHP development environment

Source: Internet
Author: User
Tags php server php debugger php development environment php web server
Build an Eclipse PHP development environment
Build 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/. During the installation process, there will be 3 text boxes, the above two input your native IP (such as: 127.0.0.1), the bottom input your email. Once the installation is complete, Apache will start automatically to test if Apache has successfully started. In the browser address bar, type: http://localhost/or http://127.0.0.1, if "It works.", then congratulations, Apache has been installed successfully, and in the lower right corner of the computer, the taskbar has a green Apache Server run icon.
PHP 5.2.11:http://www.php.net/downloads.php. Download the uncompressed package without the installation, and do not use the installer version of the installation package (many PHP extensions are not installed, such as PHP's MySQL extension, which prevents the MySQL database from being 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 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 configuration of eclipse. If you want to enable developing applications to have better internationalization support and can support Chinese output to the maximum extent, it is best to make use of UTF-8 encoding.
However, the default character encoding for the Eclipse workspace (workspace) is the default encoding for the operating system, and the default encoding for the Simplified Chinese operating system (Windows XP, Windows 2000 Simplified Chinese) is GBK or GB18030, The engineering code established in this workspace is GBK or GB18030, and the text file created in the project is also GBK or GB18030. If you want to make a new project, file directly UTF-8, you need to do the following:
Open Window->preferences->general->workspace, the "Thext file Encodiing" is best set to UTF-8, after the new Build project its Properties dialog box text file Encoding is the UTF-8.
Modify the encoding of various files: in Window->preferences->general->content type, the text below has various file formats, select the appropriate file format, in the following default encoding input box
Enter UTF-8 and click Update. For PHP development, it is best to set the HTML and PHP file encoding to UTF-8.
2, let Apache load PHP module: conf/httpd.conf, add the following at the end, that means loading PHP module, should pay attention to the version to match.
Phpinidir "d:/php/"  LoadModule php5_module "D:/php/php5apache2_2.dll"  addtype application/x-httpd-php. PHP

Note here that if your Apache is version 2.0 you will fill out loadmodule php5_module "D:/php/php5apache2.dll".
3. Add virtual directory and default homepage: The default site home directory is Apache's Htdocs directory. Because you want to place all eclipse projects under D:/php_workspace, in order to have access to the PHP files under each project, you need to create a virtual directory that points to the directory where the Eclipse project resides. To modify the httpd.conf, add 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 the PHP files under the project can be accessed via http://localhost/Workspace/ProjectDirectory.
4. PHP Configuration:
(1) The d:/php under the php.ini-recommended, renamed to PHP.ini.
(2) Set the following items:
Zend.ze1_compatibility_mode = OFF//Whether support PHP4, it is best to close it, otherwise with PHP5 processing zip file error  post_max_size = 20M     //post information Maximum capacity  MAGIC_QUOTES_GPC = Off     //Whether to use magic quotes  Extension_dir = "D:/php/ext"    //php extension  upload_max_filesize = 20M    //Upload file size  max_execution_time = 6000    //page maximum execution time (seconds)  Max_input_time =/     /script resolution time limit (seconds)  Memory_limit = 20M     //script allocation Max memory  output_buffering = on     //Open Output buffer  Implicit_flush = on     // Output buffer contents in time  

(3) Turn on Error message: In order to better debug during development, open the display_errors and display_startup_errors variables in php.ini. The purpose of the display_errors variable is obvious,
It tells PHP if the error is displayed. In addition, the default value for variable error_reporting is e_all. This setting shows all the information from bad coding practices to harmless prompts to errors. E_all is a little too thin for the development process,
Because it displays hints on the screen for small things (such as uninitialized variables), it can mess up the browser's output. If you want to see only errors and bad coding practices, but do not want to see harmless hints, you can set the following values:
error_reporting = E_all & ~e_notice

(The following configurations are optional) depending on what Apache is doing, opening the error report in PHP may not work because there may be multiple versions of PHP on the computer. It is sometimes difficult to tell which PHP version Apache is using because Apache can only view one php.ini file. It is a security issue to not know which php.ini file Apache is using to configure itself. However, there is a way to configure PHP variables in Apache to ensure that the correct level of error is set. Also, it is best to know how to set these configuration variables on the server side to veto or preempt php.ini files, providing a higher level of security. To do what has already been done in the php.ini file, add the following lines to httpd.conf, overwriting any php.ini files:
Php_flag  display_errors        on  php_value error_reporting       2039  

This overrides the flags already set for display_errors in the php.ini file, as well as the value of error_reporting. A value of 2039 represents E_all & ~e_notice. If you prefer to use E_all, set the value to 2047.
Again, you'll restart Apache.
(4) Find the dynamic extensions key, here is the PHP extension Settings section, enable the following common extensions (remove the following several previous ";" ).
Extension=php_bz2.dll  extension=php_curl.dll  extension=php_dba.dll  extension=php_dbase.dll  Extension=php_gd2.dll  extension=php_imap.dll  extension=php_ldap.dll  Extension=php_mbstring.dll  extension=php_mime_magic.dll  extension=php_mysql.dll    //mysql extension  Extension=php_mysqli.dll  extension=php_pdo.dll     //pdo extension  extension=php_pdo_mysql.dll     //pdo_mysql extension  extension= Php_sockets.dll  Extension=php_xmlrpc.dll  Extension=php_xsl.dll  

(5) Extract the Zend Debugger, the PHP version corresponding to the ZendDebugger.dll copy to the PHP installation directory, modify the php.ini, add the following:
[Zend]  Zend_extension_ts=d:/php/zenddebugger.dll    zend_debugger.allow_hosts=127.0.0.1    

Put the extracted dummy.php into the httpd documentroot directory and d:/php_workspace/to test the debugger connectivity in Eclipse (Debug configurations->php Web page->test Debugger),
Success will come out with a success message. (by modifying the WORKSAPCE's corresponding site directory, Configure "Default PHP Web Server" can also be placed in the subdirectory of the site).
(6) This step is not necessary: in order to prevent future problems, the PHP php5ts.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 a lot of problems that are difficult to solve with code-independent, Ten is because the extension does not load properly (even if the extension_dir in php.ini points to the Ext directory), this is mainly
Because the PHP module is loaded by Apache, which is two different software, there are often some collaborative issues. This is the time to copy the extension you use from ext to system32.
5. Configure Eclipse to point to the PHP module: Open Eclipse's window->preferences->php->php executables->add, 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->php Server, edit the default PHP Web server entry, change the URL to/HTTP Localhost/workspace, note that the Workspace is added to the URL bar,
This is the directory alias that was added in httpd.conf.
7, test: Restart Apache after configuration, and then create a new PHP project named Firstphptest, of course, using our d:/php_workspace as the workspace directory of Eclipse. New in the project
PHP File, such as the phpinfo.php used. Content is
 
    

When on phpinfo.php, right-click Run as->php Web Page.

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

    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.