Install Apache and PHP:
1. Download the apache version from http://www.apache.org.
2. Download the corresponding PHP version from http://www.php.net.
3. Download the corresponding PHP. MVC version from http://www.phpmvc.net.
4. Create the directory c:/www as the Web Server Directory and C:/webapp as the Web root directory,
You can also define your own directory and modify it as follows.
5. install Apache on C:/www. Open the browser and enter http: // localhost in the address bar to test whether the installation is successful.
Note: If you have installed other Web servers (such as IIS 5) on your system that occupy port 80, stop the server first.
6. Compress PHP to a directory, for example, F:/PhP5.
7. Copy the php. ini-Dist in the PHP Directory to the system directory. C:/WinNT is renamed PHP. ini.
8. According to the PHP version, here is PhP5. Copy the php5ts. dll and libxxx. DLL files to C:/winnt/system32.
9. Open the configuration file httpd. conf of Apache. Apache is installed under C:/program files/Apache Group/apache2 by default. Therefore, the configuration file is under conf in this directory.
10. Find the loadmodule line and enter loadmodule php5_module "F:/PhP5/php5apache2. dll" below (Please modify it according to your location)
11. Find the addtype line and add addtype application/X-httpd-PHP. php below.
12. Save the configuration file and open the php. ini file.
13. Find doc_root and write your Apache web root directory in the quotation marks behind the equal sign, such as doc_root = "C:/www"
14. find extension_dir and enter the ext directory address under your PhP5 directory in the quotation marks behind the equal sign, such as extension_dir = "F:/PhP5/EXT ". note: PhP4 is the extension directory.
15. find extension. There are commas (,) in front of these lines, which are annotations. You can see the DLL in the ext directory under PhP5 (PhP4 is the extension directory, then remove the preceding comma.
16. Save PHP. ini and open Apache. If there is an error, carefully check the above steps. Then write a PHP file with the following content:
<? PHP
Phpinfo ();
?>
Save it as test. php and put it in the web root directory. Open the browser and enter http: // localhost/test. php to check whether the installation is successful.
Install PHP. MVC:
1. decompress the downloaded PHP. MVC file to phpmvc under the web root directory (you can change the name by yourself ).
2. Open main. php under phpmvc and find
$ Appserverrootdir = 'C:/webapp/phpmvc '; // no trailing slash
In the middle of the quotation marks, it is the decompressed directory of phpmvc you want to modify.
$ Modulerootdir = 'C:/webapp/phpmvc '; // no trailing slash
Change the quotation mark to the same as $ appserverrootdir, because it is the main directory of phpmvc, so it is the same
$ Ostype = 'windows ';
Change the quotation mark to your operating system name. The value can only be one of UNIX, windows, and Mac.
3. Save this file and make sure that the WEB-INF under the C:/webapp/phpmvc/phpmvc-config.data directory has write permission.
4. Open your browser and enter http: // localhost/phpmvc/Main. php in the address bar? Do = stdlogon to test whether the installation is successful. (But I have never succeeded)
5. For more detailed installation documentation, please see the http://www.phpmvc.net/docs/installIdx.php? Doc = all
6. if the call to a member function on a non-object in/WEB-INF/classes/phpmvc/utils/bootutils appears. PHP error, please first Delete the/WEB-INF/phpmvc-config.data file content, then manually modify the phpmvc-config.xml, such as adding a space (just need to make PHP. MVC detected that the file has been modified, need to regenerate the phpmvc-config.data file ).
Official example of installing PHP. MVC: (optional)
1. Note: This instance application requires the class library version to ask PHP. MVC beta 0.3.4 or higher.
2. Download the app: php. MVC users guide 101 example. (http://www.phpmvc.net/download/rel/phpmvc-guide-101.zip)
3. decompress the package to the web root directory, for example, C:/webapp/salesreports.
4. Edit the main. php file and set the path of the php. MVC class library and application program as follows:
$ Appserverrootdir = 'C:/webapp/phpmvc '; // no trailing slash
Change the quotation marks to the decompressed directory of your phpmvc.
$ Modulerootdir = 'C:/webapp/salesreport'; // no trailing slash
Change the quotation marks to the decompress directory of your example program.
5. Test the application. Access address http: // localhost/salesreports/Main. php? Do = salesreport (this is my test succeeded)
Develop a project:
1. Create a directory under the web root directory, such as study
2. Copy the main. php and WEB-INF directories under the phpmvc unzip directory to the study directory, we want to remove the files we don't need
3. Go to the WEB-INF directory and delete directories and files except. htaccess, modulepaths. php, phpmvc-config.xml, phpmvc-config_1_1.dtd, prepend. php
4. go back to the upper-level directory and modify main. PHP file (in fact, this file is the mvc c, that is, the Controller), find $ modulerootdir and modify the directory of this project, such as: C:/webapp/Study
5. You also need to modify $ actiondispatcher, which needs to be modified later.
6. in the WEB-INF to create a new classes directory, put actionform, action and actiondispatcher class (these classes can refer to the above example, here will not mention ). write the actiondispatcher class to main. go to $ actiondispatcher in PHP.
7. you can write some PHP files in the upper-level directory of the WEB-INF for display (that is, the mvc v, that is, the view ), then configure the WEB-INF under the phpmvc-config.xml (you can refer to the example or view official website tutorials ).
8. Enter http: // localhost/study/Main. php in the browser? Do = xxx
Xxx represents some of the actions you configured in the phpmvc-config.xml. See if your project is successful.
Use the ADODB connection pool that comes with phpmvc:
1. Download the ADO library, which can be found at http://www.phpe.net/class/106.shtml.
2. Unzip it to your phpmvc unzip directory under the WEB-INF/lib, so your ADO library may be under C:/webapp/phpmvc/WEB-INF/lib/ADODB
3. open globalpaths under C:/webapp/phpmvc/WEB-INF. PHP. In function getglobalpaths (), you can see many $ appdirs [] and add a line to these $ appdirs: $ appdirs [] = 'web-INF/lib/adodb ';
Specify your ADO library directory
4. Save the file, open globalprepend. php, and add:
Export de_once 'web-INF/lib/ADODB. Inc. php'; // master file of ADO
Export de_once 'web-INF/lib/ADODB/Drivers/adodb-mysqlt.inc.php '; // ADO driver for MySQL
Include_once 'adodbdatasource. php'; // The ADO interface file that comes with phpmvc
5. Save the file and open the phpmvc-config.xml file and add it to the <phpmvc-config> tab:
<Data-sources>
<Data-source key = "adodb_mysql_data_source" type = "adodbdatasource">
<Set-Property = "host" value = "localhost"/>
<Set-Property = "databasetype" value = "MySQL"/>
<Set-Property = "Database" value = "study"/>
<Set-Property = "username" value = "root"/>
<Set-Property = "password" value = "123456"/>
<Set-Property = "persistent" value = "false"/>
</Data-source>
</Data-sources>
Modify the value in the value according to the actual situation. The value of databasetype depends on the database you are using. The values of different databases are different. Here is MySQL.
6. Find the adodbdatasource. php under the WEB-INF/classes/phpmvc/DBCP directory, This is the ADO interface file of phpmvc, but this file cannot work, you need to modify it.
First, its annotations are not extended. In the file class definition class adodbdatasource extends adodb_mysqlt, the annotations are not well stored. You need to add /*
And even though you have set database information in the phpmvc-config.xml, it seems that not all of it can be obtained, you need to add the following before $ this-> pconnect in function open:
$ This-> databasetype = 'mysql'; // specify that the database is MySQL.
$ This-> database = 'Study '; // specify the database name as study. Change the name as needed.
7. Save the file. Now you can use ADO, where you need to connect to the database, such as in actionform and action.
The method is:
$ Dskey = 'ADODB _ mysql_data_source '; // This is the key you set in the phpmvc-config.xml
$ Db = & $ this-> actionserver-> getdatasource ($ dskey); // get the connection
$ SQL = "select * from user"; // SQL statement
$ Recordset = & $ db-> execute ($ SQL); // Execute
If (! $ Recordset)
{
Exit ($ db-> errormsg ());
}
$ Rowarray = $ recordset-> fetchrow (); // get record
If (! $ Rowarray)
{
Exit ($ db-> errormsg ());
}
Echo $ rowarray ['username']; // modify the content in quotation marks to your field name.
Echo $ rowarray ['Password'];
$ Recordset-> close (); // close the connection
$ Db-> close (); // close the connection
8. Run your program now.
Internationalization:
1. you can use. properties file to record all the text to be displayed, so that you do not need to encode the text in the view, so that we can use multiple. properties file to display languages of different countries
2. In this example, we write a small file: My. properties. content:
# The well number is a comment
Logon. username. reqd = enter a valid user name [{0}]
Logon. Password. reqd = enter a valid Password [{0}]
Don't worry about anything in []. We will talk about it later.
3. Save the file to the WEB-INF/classes, where it is placed together with the action class
4. Now you can use them. Write the following code where files are needed:
$ Config = 'my'; // enter the name of your property file. If you do not need to write. properties, the program will automatically find it.
$ Defalocallocale = new locale (); // Default Time Zone
$ PMR = new propertymessageresources (null, $ config, false );
$ PMR-> setdefalocallocale ($ defalocallocale );
// Start to output text
Echo @ $ PMR-> getmessage ($ defalocallocale, 'logon. username. reqd ');
The quotation marks indicate the attribute name defined in the attribute file of the text to be output.
Now I can use @ in front of it because the 'notice' information may appear to damage the display.
If you think the above is too wordy, you can write the previous statement output in a PHP file, such as global. php, and then each page contains it.
5. now the content in the property file is clearly output when the user name and password are incorrect, so we also want to display the invalid user name and password when outputting, then we only need to add [{0}] after the property name to be displayed. we may also want to display multiple pieces of information, so we can write [{0}] [{1}], so that we can push it like this.
6. Now we need to judge the legality of the user name and password in actionform, and output the error message if it is invalid. How can we pass the error user name to [{0? Follow me:
$ ARGs = array ($ username); // $ username indicates the wrong username. If there are multiple usernames, they can all be placed in this array.
// Output now
Echo @ $ PMR-> getmessage ($ locale, 'logon. username. reqd ', $ ARGs );
7. Now we will make an English version. Copy the my. properties file to my_en_us.properties, modify the text in the file to English, and save
8. Modify the global. php file we just created:
$ Defalocallocale = new locale ('en _ us'); // change to the U.S. time zone. The language is English.
9. now let's take a look at the output. Is the output already in English. if you do not know the country and language code, for example, en_us, you can find