Cake is a php framework based on RubyonRails. Like RoR, Cake also encapsulates database control. Currently, Cake is not a mature framework, but it is worth noting. How to install Cake on WAMP
Cake is a php framework based on Ruby on Rails. Like RoR, Cake also encapsulates database control. Currently, Cake is not a mature framework, but it is worth noting.
The following describes how to install Cake on WAMP.
First Download Cake Latest version: cake_0.2.9.zip
After decompression, enter cakeconfig to change database. php. default to database. php, and set database parameters. For example:
$ DATABASE_CONFIG = array (
'Devel '=> array (
'Host' => 'localhost ',
'Login' => 'user ',
'Password' => 'user ',
'Database' => 'Cake'
)
);
Then Cake needs to use Apache mod_rewrite, open Apache/config/httpd. conf, and
# LoadModule rewrite_module modules/mod_rewrite.so
Before,
Set
# AddModule mod_rewrite.c
The first # is dropped.
Then add a VM, such
ServerAdmin Easy@gmail.com
DocumentRoot 'f:/cake /'
ServerName cake.com
ErrorLog logs/cake.com. error_log
CustomLog logs/cake.my.com common
AllowOverride all
Order allow, deny
Allow from all
In C: WINDOWSsystem32driversetchosts, add a local host line.
127.0.0.1 cake.com
Restart Apache and the browser.
Now Cake can work properly. Let's create a Exploitation:
Create a table in the database
CREATE TABLE posts ( id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY, title VARCHAR(50), body TEXT, created DATETIME DEFAULT NULL, modified DATETIME DEFAULT NULL);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());
。
Cake is based on the MVC mode. When creating an application, we first create its Model.
app/models/post.php
Create Control
app/controllers/posts_controller.php
Here, the index method is used:
app/controllers/posts_controller.php (fragment) function index () {}
Create view
app/views/posts/index.thtml
ID |
Title |
Created |
post->find_all() as $post): ?>
|