Preparation of the Eclipse PHP development environment

Source: Internet
Author: User
Building the Eclipse PHP development environment

Because recently to use PHP to do development, ready to set up the environment, in the Internet for a long time did not find a particularly comprehensive approach, their own combined with their own online to provide some methods to write this article

1. Software Preparation

MySQL: Download Address: http://www.mysql.com/downloads/mysql/, my version is Mysql-essential-5.1.55-win32.msi,

Apache: Download Address: Http://httpd.apache.org/download.cgi#apache22, my version is Httpd-2.2.22-win32-x86-no_ssl.msi

PHP: Download Address: http://windows.php.net/download/, my version is Php-5.2.17-win32-vc6-x86.zip, Note: VC6 is supported by Apache server, VC9 is supported by IIS , at the same time it is divided into thread-safe version and non-thread-safe version, in the installation of Zenddebugger to select the corresponding version of the configuration file to correspond to, my version is Php-5.2.17-win32-vc6-x86.zip, do not use the installer version of the installation package (with this word many PHP extensions are not installed, such as the MySQL extension of PHP, resulting in the inability to connect to the MySQL database)

Zend debugger:http://downloads.zend.com/pdt/server-debugger/, or http://www.zend.com/en/products/studio/. Downloads Choose Studio Web Debugger, my version is the one under the previous link Zenddebugger-5.2.15-cygwin_nt-i386.zip

Eclipse for PHP:HTTP://WWW.ECLIPSE.ORG/DOWNLOADS/PACKAGES/RELEASE/GALILEO/SR2, note download the Galileo version, Helios version of the configuration server when there is a problem and indigo currently does not have this version, my version is Eclipse-php-galileo-sr2-win32.zip, the workspace is: d:/myworkspaces/ Phpworkspace. 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.

2. Installation Configuration

Install the Apache,mysql in turn and unzip the PHP zip package. Specific MySQL configuration Please refer to other documents, this information is very full.

2.1 Configuring Apache to load PHP modules

Conf/httpd.conf, add the following at the end to indicate loading the PHP module.

#BEGIN PHP INSTALLER edits-remove only on Uninstallphpinidir "D:/program files/php/" LoadModule php5_module "D:/program F Iles/php/php5apache2_2.dll "AddType application/x-httpd-php. php #END php INSTALLER edits-remove only on UNINSTALL

Note here that if your Apache is version 2.0 you will fill out loadmodule php5_module "D:/php/php5apache2.dll".

?

Create a file in the Apache document directory (default to Apache installation directory/htdocs) index.php Enter the following:

 
  

?

Restart Apache
Entering http://localhost/index.php in the browser will show PHP version information that PHP and Apache have been successfully built

2.2 Adding a virtual directory and default home page

The default site home directory is the Apache Htdocs directory. Because you want to place all eclipse projects under D:/myworkspaces/phpworkspace, 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:/myworkspaces/phpworkspace/"  
 
  
   
       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 through the http://localhost/Workspace/program directory.

2.3PHP 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, and it tells PHP if it shows an error. 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 bit too thin for the development process because it shows hints on the screen for small things (such as uninitialized variables), which 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  

? (4) Find the dynamic extensions key, here is the PHP extension Settings section, enabling the following common extensions (remove the following items in front of the ";" )。

    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      Extension=php_zip.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, note that NTS refers to non-thread-safe:

[Zend]  Zend_extension_ts=d:/program files/php/zenddebugger.dll    zend_debugger.allow_hosts=127.0.0.1    zend_ Debugger.expose_remotely=always  

? 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), 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.

2.4Eclipse Configuration

2.4.1 configuring Eclipse to point to the PHP module

Open Eclipse's window->preferences->php->php executables->add,

2.4.2 Configure the php file access URL in eclipse:

Open window->preferences->php->php Server and edit the default PHP Web server entry

Note that workspace is added to the URL bar, which is the directory alias added in httpd.conf.

2.4.3 Configuring Debug

PHP Debug, as shown, select the appropriate debugger,server

At this point, the configuration is complete.

Remember to restart Apache.

2.5 Testing

Restart Apache after configuration, and then create a new PHP project named Firstphptest, with our d:/php_workspace as the workspace directory of Eclipse. Create a new PHP File in the project, such as the phpinfo.php used. Content is

    
 
    

? When you right-click Run as->php Web page on index.php, you'll see something like this:


  • 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.