Php development environment installation-three-in-one (appserv)
1. Install the MySQL + PHP + Apache Integrated Environment
Download the MySQL + PHP + Apache integration package we have prepared for you, decompress it, and click the only installation file in the directory to go to the Environment wizard for installation.
Start Apache 2.4.10 Server Installation and click Next]
Accept the agreement. I think you will not hesitate to agree with this completely free GNU agreement! Click [I Agree]
You can choose to install the directory folder. It is best to increase the available space! Click Next]
Select All. Click Next]
Apache HTTP Server Apache Web/HTTP Server
- MySQL database
- PHP Hypertext Preprocessor PHP
- PhpMyAdmin manages MySQL database Web Applications
This step requires a bit of content
- Server Name: the name of the server. You can enter one as needed.
- Administrator's email address: Administrator email address. Enter your email address.
- Apache HTTP port is port 80 by default. You can leave it empty when you are sure that port 80 is not occupied. If you want to install IIS, you 'd better set another port, it is best to unify it into 8080.
Click Next]
Set MySQL database
- Enter root password and enter the database access password. That is, the password of the root account.
- The following describes how to enable InnoDB to use the database transaction processing engine.
- No other changes are required.
Click Install.
The last panel tells you that the installation is complete. Click Finish to start the Apache and MySQL services. If security guard 360 is installed, a dialog box will pop up asking if the appserv can be started automatically when the server is started. We recommend that you enable the appserv automatically when the server is started, apache or MySQL stops the service for a period of time after each manual start, which may be related to anti-virus software.
2. Test the installation environment ¶
- After the installation, we need to perform a test. Open your browser and type http: // localhost: 8080 in the address bar. Can the page be displayed normally?
If you can see this result, click phpmyadmindatabase Manager version 2.10.3. In the pop-up dialog box, enter the account and password. The account is root and the password is clear.
Go to this page and use phpMyAdmin to view the database information.
- TestCommand PromptThe availability of PHP.
Open the command prompt interface and enter PHP-V
If you have not guessed the error, a similar error dialog box will pop up. This is a small bug after installation of the installation package, so we need to correct it.
Enter PHP. ini to open the PHP configuration file.
Locate the row by searching for php_mbstring.dll. We need to cut this line and put it above, as shown in.
Save, and then type PHP-V at the command prompt.
This command displays the PHP version information, OK.
Php development framework --- install idea in the symfony Environment ¶
1. Install the pear Environment Plugin of PHP ¶
What is pear?Pear is a framework distribution system that shares available PHP components.We can use pear to directly find and download the useful PHP code or components we want. Here you can think that symfony is a usable component, pear will be used later to install the symfony environment, but you must first install pear. Pear is based on the PHP environment, so the following is much simpler. Go!
Open your appserv installation directory and find the address
Click,Go-pear.batFor batch files, go to the command line prompt. Here I will not go into details, and you will be able to press enter all the time. Note that after you press Enter next, you must wait for the installation of pear. Finally, click the registration file pear_env.reg in the current directory.
To test whether pear works properly, type pear at the command line prompt.
2. Use pear to install the symfony Development Environment idea ¶
Reference addressHttp://pear.symfony-project.com/
Open a command prompt and enter the following command
- Register the symfony pear channel:
Pear channel-discoverpear.symfony-project.com
- List available installation packages:
Pear remote-list-C symfony
Pear install symfony/symfony
Please wait for the last step .... The installation package is not very large. It is estimated that the installation package is less than 4 MB, depending on the speed of your network.
3. debug the symfony Development Environment Development ¶
Finally, let's debug whether the symfony environment is running normally. This step is very simple. Type
Symfony-V
So far, symfony is successfully installed.
Use symfony to quickly generate a project --- Hello World Workshop ¶
1. Install a php development tool. We recommend that you use eclipse for PHP development ¶
To make project development more convenient, we still need an excellent development tool for assistance. Here we chose eclipse, which has many versions, such as Zend version and green version, here we use a simple installation version called easyeclipse. In the future, you can consider better features. The installation method is very simple. To run the installation program, you do not need to install JDK in one step, because this tool is used in Java.
This is the general appearance of the Tool. For the use of this tool, we will not explain it here, but will give a brief introduction to the project development needs.
2. Operate the CLI command of symfony at the command prompt. Bytes ¶
The development of symfony is different from other framework technologies. It has built-in CLI commands (and can be customized). Many things can be completed only by several command operations, as a professional developer, this is a great gospel. For beginners, you don't have to worry about it. In fact, it's no different from the doscommand. It just takes some time to remember words. Okay, come on.
- Open a command prompt and create the symfony project work directory, symfony. All the subsequent projects are stored in this directory.
- Go to the symfony directory and create a project directory. Hello
- Enter the directory folder, and enter symfony generate: Project hello to create the project hello. This command will generate the symfony project directory architecture, which will be explained later.
- Run the "continue" command and enter symfony generate: app frontend to create an application frontend of the project. This command will generate the directory architecture of the symfony application.
- Next, add the hello project to eclipse.
Switch to the eclipse work directory. After confirming, restart the tool.
Create a PHP project, select a PHP project in the dialog box, and click Next.
Enter hello, and end with the generated symfony project.
This is the final project directory structure, which will be explained later.
3. Configure an independent access domain name for the project ¶
Because the generated project is not in the Apache WWW directory, we cannot access it in the conventional way. Here we need to configure the apache service configuration file and configure an independent subdomain name for the hello project. This will benefit the development of multiple projects in the future.
Open the Apache configuration file directory
Open the httpd. conf configuration file in notepad and enter the following content at the bottom. Pay attention to your appserv installation directory.
Indexignore .?? **~ * # Header * readme * rcs cvs *, V *, T
Namevirtualhost FIG: 8080
# Set localhost or parse it to the WWW directory folder
<Virtualhost127.0.0.1: 8080>
Servername localhost
DocumentRoot "C:/appserv/www"
Directoryindex index. php
<Directory "C:/appserv/www">
AllowOverride all
Allow from all
</Directory>
</Virtualhost>
# Set hello. localhost to parse to the symfony work directory, hello/Web
<Virtualhost127.0.0.1: 8080>
Servername hello. localhost
DocumentRoot "C:/symfony/Hello/Web"
Directoryindex index. php
<Directory "C:/symfony/Hello/Web">
AllowOverride all
Allow from all
</Directory>
# Reference symfony's built-in resource files, including CSS and JS
Alias/SFC:/appserv/PhP5/data/symfony/web/SF
<Directory "C:/appserv/PhP5/data/symfony/web/SF">
Allowoverrideall
Allow from all
</Directory>
</Virtualhost>
# If you have multiple projects, configure a virtualhost. For example, if you have a CMS project, add the following code to the configuration file:
<Virtualhost127.0.0.1: 8080>
Servername cms. localhost
DocumentRoot "C:/symfony/CMS/Web"
Directoryindex index. php
<Directory "C:/symfony/CMS/Web">
AllowOverride all
Allow from all
</Directory>
Alias/SFC:/appserv/PhP5/data/symfony/web/SF
<Directory "C:/appserv/PhP5/data/symfony/web/SF">
Allowoverrideall
Allow from all
</Directory>
</Virtualhost>
Next, complete the parsing configuration of Hello. localhost, CMS. localhost.
Open the directory c: \ windows \ system32 \ drivers \ etc \,
Open the hosts file in notepad, which is used to configure host domain name resolution.
Enter hello. localhost in the lower part. The port number is not required here. What have you guessed in the above line.
Now restart the apache service:
In your browser, type http://hello.localhost: 8080 to display the page, prompting you that you have created a symfony project. This is a temporary page. You can write some code below.
4. write code to implement Hello world. Bytes ¶
Next we will continue to run the symfony command under the command prompt
Symfony generate: module frontend home
Create a module home under the frontend Application
Go back to tool refresh Project
Or press F5 to select a project.
Open the file actions. Class. php In the directory folder, and comment out a unique line of code. Write the code as shown in the following figure.
Open the file indexsuccess. php In the figure directory. This file is a template file and code is written as shown in the figure.
Enter http://hello.localhost: 8080/index. php/home in the address bar of the browser, so far we have completed this small classic example.
Finally: I want to write this after watching the video, but my colleague, Yuan Mao, has already written the shoes and I will use them directly. You can also share your resources. Thank you for your reference.