CakePHP framework home: http://www.cakephp.org/
Import the downloaded directory to the project. The directory structure is shown in figure (Version: 1.1.19.6305)
Set up the PHP environment. Here AppServ2.5.9 is used.Home http://www.appservnetwork.com/
Create a database blog in MySQL and run the following SQL statement to create a table.
/**/ /*First, create our posts table:*/
CREATE TABLE Posts (
Id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY ,
Title VARCHAR ( 50 ),
Body TEXT ,
Created DATETIME DEFAULT NULL ,
Modified DATETIME DEFAULT NULL
);
/**/ /*Then insert some posts for testing:*/
INSERT INTO Posts (title, body, created)
VALUES ( ' The title ' , ' This is the post body. ' , NOW ());
INSERT INTO Posts (title, body, created)
VALUES ( ' A title once again ' , ' And the post body follows. ' , NOW ());
INSERT INTO Posts (title, body, created)
VALUES ( ' Title strikes back ' , ' This is really exciting! Not. ' , NOW ());
Modify the file name of database. php. default in the app/config/directory of the project to database. php, and modify its configuration.
Modify the httpd. conf file of Apache.
Apache2.2 directly# LoadModule rewrite_modulemodules/mod_rewrite.so.
In versions earlier than 2.0, it is said that two places should be modified:LoadModule rewrite_module libexec/httpd/mod_rewrite.soAndAddModule mod_rewrite.c
Add Model:
/App/models/post. php
Code:
<? Php
Require_once ( ' Cake/app_model.php ' );
Class Post Extends AppModel {
Public $ Name = ' Post ' ;
Public $ Validate = Array (
' Title ' => VALID_NOT_EMPTY ,
' Body ' => VALID_NOT_EMPTY
);
}
?>