I installed cakephp 2.9.7 and i am doing blog tutorial by referring(https://book.cakephp.org/2.0/en/tutorials-and-examples/blog/part-two.html).
Create a Post model
class Post extends AppModel {
}
Creating a Post controller
class PostsController extends AppController {
public $helpers = array('Html', 'Form');
public function index() {
$this->set('posts', $this->Post->find('all'));
}
}
Creating Post Views.I created Posts folder inside app/View folder.And i updated Database.php too so that it can connect to mysql database.
<!-- File: /app/View/Posts/index.ctp -->
<h1>Blog posts</h1>
<table>
<tr>
<th>Id</th>
<th>Title</th>
<th>Created</th>
</tr>
<!-- Here is where we loop through our $posts array, printing out post info -->
<?php foreach ($posts as $post): ?>
<tr>
<td><?php echo $post['Post']['id']; ?></td>
<td>
<?php echo $this->Html->link($post['Post']['title'],
array('controller' => 'posts', 'action' => 'view', $post['Post']['id'])); ?>
</td>
<td><?php echo $post['Post']['created']; ?></td>
</tr>
<?php endforeach; ?>
<?php unset($post); ?>
</table>
But when i run in my local cakephp/app error says Error: The view for AppController::index() was not found.Confirm you have created the file: App/index.ctp in one of the following paths: cakephp/app/View/App/index.ctp.stuck with solving this as i am new to cakephp.
cakephp/posts
– tarikul05