0

I am working on creating a UI for a database using cakephp. I am very new to cakephp so I am a little stuck. I have successfully installed cakephp, connected it to the database. I have created the model, controller and view based on tutorials but when I try to load this page localhost/app this is the error I get Any help will be highly appreciated.

This is the path to my controller: app/controller/OutagesController.php model: app/model/Outage.php view: app/View/Outages/index.ctp and my code is below Also, Am I loading the right URL? Thanks in advance Tayo6.

enter code here
Error message:
Missing View
ERROR: THE VIEW FOR APPCONTROLLER::INDEX() WAS NOT FOUND.
ERROR: CONFIRM YOU HAVE CREATED THE FILE:         /USERS/ESTHER.AGBAJI/SITES/CAKE/APP/VIEW/APP/INDEX.CTP
Notice: If you want to customize this error message, create     app/View/Errors/missing_view.ctp
Stack Trace
    CORE/Cake/View/View.php line 468 → View->_getViewFileName(null)
    CORE/Cake/Controller/Controller.php line 948 → View->render(null, null)
    CORE/Cake/Routing/Dispatcher.php line 194 → Controller->render()
    CORE/Cake/Routing/Dispatcher.php line 162 → Dispatcher->_invoke(AppController, CakeRequest, CakeResponse)
    APP/webroot/index.php line 110 → Dispatcher->dispatch(CakeRequest, CakeResponse)
APP/index.php line 19 → require(string)


MODEL CLASS (Outage.php)
<?php


class Outage extends AppModel {
    var $name = 'Outages';
}

var $validate = array(
'id' => array(
'rule' => 'notEmpty'),

'start_date' => array(
'rule'=>'date'
'allowEmpty' => true),

'end_date' => array(

'allowEmpty' => true),

'application' => array(

'allowEmpty' => true),

'environment' => array(

'allowEmpty' => true),

'business_impact' => array(
'allowEmpty' => true),

'notified_by' => array(
'allowEmpty' => true),

'details' => array(
'allowEmpty' => true),

'severity' => array(
'rule' => 'notEmpty'),

'state' => array(
'allowEmpty' => true),

'resolved' => array(
'rule' => 'notEmpty')

'jira' => array(

'allowEmpty' => true)

);

 ?>

CONTROLLER CLASS (OutagesController.php)

<?php

class OutagesController extends AppController {

    var $name = 'Outages';
    var $helpers = array('Html', 'Ajax', 'Javascript');
   function index() {

    $this->set('outages', $this->Outage->find('all'));
    }
    function view($id = null) 
    {
    $this->Outage->id = $id;
    $this->set('outage', $this->Outage->read());
    print_r($this->viewVars);
    }
    $this->Outages->set($this->request->data);

}

?>
VIEW (index.ctp)

 <h2>Outages</h2>

<table>
    <tr>

        <th>Id</th>
        <th>Start date</th>
        <th>End date</th>
        <th>Application</th>
        <th>Environment</th>
        <th>Business impact</th>
        <th>Notified by</th>
        <th>Details</th>
        <th>Severity</th>
        <th>State</th>
        <th>Resolved</th>
        <th>Jira</th>

    </tr>

 <?php foreach ($outages as $outage: ?>

    <tr>
        <td><?php> echo $outage['Outage']['id']?></td>

        <td>
        <?php> echo $html->link(($outage['Outage']['start_date'],
        array('controller'=> 'outages', 'action'=> 'view', $outage['Outage']['id']));?>
        </td>

        <td><?php echo $outage['Outage']['end_date']; ?></td>
</tr>

 <?php endforeach; ?>
</table>    

Thank you so much for your useful responses. I am now loading it the right way, using localhost/outages but I get this error message: Not Found The requested URL /outages was not found on this server. I have gone through my files and made sure they are in the right places. Tayo6

2
  • Thank you so much for your useful responses. I am now loading it the right way, using localhost/outages but I get this error message: Not Found The requested URL /outages was not found on this server. I have gone through my files and made sure they are in the right places. Tayo6 Commented Jul 16, 2013 at 15:35
  • For those who came here from search. In my case beforeFilter() caused this problem. See stackoverflow.com/questions/16921021/… for more info. Commented Nov 29, 2016 at 18:23

2 Answers 2

1

It's difficult to tell exactly which URL from your description, but assuming you let localhost point directly to your webapplication, it should be http://localhost/outages

By using localhost/app you're trying to get the index of the 'AppController' (which exists, but is normally not used directly). To get a 'home' page for your app, your should use the PagesController.

Sign up to request clarification or add additional context in comments.

Comments

0

Everything seems to be correct perhaps only problem is in the URL you are trying to access.

Try to access with the application root folder name which contains /app, /lib, /vendors etc.

For e.g. http://localhost/testapp

The first page to be run on browser, you can make that setting in app/Config/routes.php

Router::connect('/', array('controller' => 'outages', 'action' => 'index'));

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.