PHP Development Environment

Source: Internet
Author: User
Tags php server php debugger php development environment php web server phpinfo

PHP generally uses XAMPP (Apache+mysql+php+perl) deployment, https://www.apachefriends.org/zh_cn/index.html. This article does not need the integration package, constructs the PHP development environment:

1. Prepare and install the following software:
mysql:http://dev.mysql.com/downloads/.
apache: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: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 the PHP module:Conf/httpd.conf, add the following at the tail, that means loading PHP modules, note that the version to match.

[Python]View PlainCopy
    1. Phpinidir "d:/php/"
    2. LoadModule php5_module "D:/php/php5apache2_2.dll"
    3. 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:

[Python]View PlainCopy
    1. alias/workspace/ "d:/php_workspace/"
    2. <directory "d:/php_workspace/" >
    3. Options Indexes MultiViews
    4. allowoverride None
    5. Order Allow,deny
    6. Allow from all
    7. </Directory>

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:

[CPP]View PlainCopy
  1. Zend.ze1_compatibility_mode = off //Whether support PHP4, it is best to close it, otherwise the zip file with PHP5 error
  2. Post_max_size = 20M //post information Maximum capacity
  3. MAGIC_QUOTES_GPC = Off //Use magic quotes
  4. Extension_dir = "D:/php/ext" //php extension
  5. Upload_max_filesize = 20M //upload file size
  6. Max_execution_time = 6000 //page maximum execution time (seconds)
  7. Max_input_time =/ /script parsing time limit (seconds)
  8. Memory_limit = 20M //script allocates maximum memory
  9. output_buffering = on //whether the output buffer is open
  10. Implicit_flush = on //timely output buffer contents

(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:

[Python]View PlainCopy
    1. 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: [Python]View PlainCopy
    1. Php_flag display_errors on
    2. 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 ";" ).

[CPP]View PlainCopy
  1. Extension=php_bz2.dll
  2. Extension=php_curl.dll
  3. Extension=php_dba.dll
  4. Extension=php_dbase.dll
  5. Extension=php_gd2.dll
  6. Extension=php_imap.dll
  7. Extension=php_ldap.dll
  8. Extension=php_mbstring.dll
  9. Extension=php_mime_magic.dll
  10. Extension=php_mysql.dll //mysql Extension
  11. Extension=php_mysqli.dll
  12. Extension=php_pdo.dll //pdo Extension
  13. Extension=php_pdo_mysql.dll //pdo_mysql Extension
  14. Extension=php_sockets.dll
  15. Extension=php_xmlrpc.dll
  16. Extension=php_xsl.dll
  17. 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:

[Python]View PlainCopy
    1. [Zend]
    2. Zend_extension_ts=d:/php/zenddebugger.dll
    3. zend_debugger.allow_hosts=127.0. 0.1
    4. 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), 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 and 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, and change the URL to http://localhost/Workspace. Notice 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, with our d:/php_workspace as the workspace directory of Eclipse. New in the project
PHP File, such as the phpinfo.php used. Content is

[PHP]View PlainCopy
    1. <?php
    2. Phpinfo ();
    3. ?>

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

PHP Development Environment

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.