Home >Backend Development >PHP Tutorial >Overcoming CakePHP (Ruby On Rails Framework in PHP) Graphic Introduction Page 1/2_PHP Tutorial

Overcoming CakePHP (Ruby On Rails Framework in PHP) Graphic Introduction Page 1/2_PHP Tutorial

WBOY
WBOYOriginal
2016-07-21 15:49:03856browse

CakePHP框架首页: http://www.cakephp.org/

下载后导入工程中,目录结构如下图(使用版本:1.1.19.6305)

搭建PHP环境,这里使用了AppServ2.5.9。 下载主页 http://www.appservnetwork.com/

MySQL中新建数据库blog,并运行如下SQL文建表。

/* 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());

修改工程app/config/目录下database.php.default文件名为database.php,并修改其配置。

修改Apache的httpd.conf文件。

Apache2.2版本的,直接把#LoadModule rewrite_modulemodules/mod_rewrite.so的注释删掉即可。

2.0以前的版本,据说要修改2个地方: LoadModule rewrite_module libexec/httpd/mod_rewrite.soAddModule mod_rewrite.c

增加Model:

/app/models/post.php

代码:

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

    );
}

?>

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/319633.htmlTechArticleCakePHP framework homepage: http://www.cakephp.org/ After downloading, import it into the project. The directory structure is as follows (Used version: 1.1.19.6305) To build a PHP environment, AppServ2.5.9 is used here. Download...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn