need help to run cakephp programe

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
manojsemwal1
Forum Contributor
Posts: 217
Joined: Mon Jun 29, 2009 4:13 am
Location: India

need help to run cakephp programe

Post 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....
User avatar
AbraCadaver
DevNet Master
Posts: 2572
Joined: Mon Feb 24, 2003 10:12 am
Location: The Republic of Texas
Contact:

Re: need help to run cakephp programe

Post 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.
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
manojsemwal1
Forum Contributor
Posts: 217
Joined: Mon Jun 29, 2009 4:13 am
Location: India

Re: need help to run cakephp programe

Post 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
manojsemwal1
Forum Contributor
Posts: 217
Joined: Mon Jun 29, 2009 4:13 am
Location: India

Re: need help to run cakephp programe

Post by manojsemwal1 »

pl help required
.............................on the above post

thankss
Post Reply