The graphic introduction to CakePHP (RubyOnRails framework in PHP) page 1. CakePHP framework home page: www.cakephp.org download and import to the project. the directory structure is as follows (use version: 1.1.19.6305) to build the PHP environment. here AppServ2.5.9 is used. Download 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');
ClassPostExtendsAppModel {
Public $ Name = 'Post';
Public $ Validate = Array(
'Title' =>VALID_NOT_EMPTY,
'Body' =>VALID_NOT_EMPTY
);
}
?>
Idea http://www.cakephp.org/after the download import project, directory structure such as (using version: 1.1.19.6305) to build the PHP environment, here using AppServ2.5.9. Download...