Page 1 of 1

need help to run cakephp programe

Posted: Mon Sep 13, 2010 7:50 am
by manojsemwal1
hai iam new bibe in cake php and iam learning cake php i have read tutorial but some confusion is there.
1 how to check cake php is installed in my pc .
2-.ctp file in not working in my pc.

i have trying some simple coding like:
Ex:
Database table : books
Model class : Book
Controller class : BooksController
View found at : /app/views/books/index.ctp
coding are:

Sample model
<?php
class Book extends AppModel
{
var$name = 'Book';
var$validate = array(
'title' => array(
'rule' => 'notEmpty'
),
'author' => array(
'rule' => 'notEmpty'
)
);
}
?>

Sample Controller

<?php
class BooksControllerextends AppController{
var$name = 'Books';
var$helpers = array('Html','Ajax','Javascript');
function index()
{
$this->set('books', $this->Book->find('all'));
}
function view($id = null) {
$this->Book->id = $id;
$this->set('book', $this->Book->read());
print_r($this->viewVars);
}
}

Sample view

<h1>Books</h1>
<table>
<tr>
<th>Id</th>
<th>Title</th>
<th>Author</th>
</tr>
<?phpforeach($books as $book: ?>
<tr>
<td><?phpecho $book*‘Book'+*'id'+; ?></td>
<td>
<?phpecho $html->link($book*‘Book+*'title'+,
array('controller' => ‘books’, 'action' => 'view', $book*‘Book+*'id'+)); ?>
</td>
<td><?phpecho $book*‘Book+*‘author'+; ?></td>
</tr>
<?phpendforeach; ?>
</table>

i have created three folder under cakephp like model,controller,views and inside views i have save the view file index.ctp but its display simple code.
My query is how to run the sample view file . and where i have to save the file.
Thanks
waiting for your helpful answer....

Re: need help to run cakephp programe

Posted: Mon Sep 13, 2010 10:24 am
by AbraCadaver
You don't run the view file. Everything is run from the root index.php which loads the appropriate controller, model and view. You should really read the installation tutorial and run the 'cake' console script to setup your application.

Re: need help to run cakephp programe

Posted: Tue Sep 14, 2010 7:19 am
by manojsemwal1
Thanks AbraCadaver
I have indtalled the Cake php and tried to run it showing the page as below

CakePHP: the rapid development php framework
Release Notes for CakePHP 1.2.0.7692 RC3.
Read the release notes and get the latest version
Your tmp directory is writable.

The FileEngine is being used for caching. To change the config edit APP/config/core.php

Your database configuration file is present.

Cake is able to connect to the database.


now how can i reach my application as per above php files which is placed in model views and controller folder.

Thanks

Re: need help to run cakephp programe

Posted: Wed Sep 15, 2010 4:47 am
by manojsemwal1
pl help required
.............................on the above post

thankss