views:

34

answers:

1

HI! I'm trying to create the web service in the cakePhp. I'm new to cakePhp and only recently start working on it. I found a useful tutorial at http://www.littlehart.net/atthekeyboard/2007/03/13/how-easy-are-web-services-in-cakephp-12-really-easy/ I created both the controller and index.ctp files as described in the tutorial. But when I typed the url (http://localhost:81/cakephp/foo) of the controller to run the file, I got the following error:

// controllers/recipes_controller.php
/**
 * Test controller for built-in web services in Cake 1.2.x.x
 *
 * @author Chris Hartjes
 *
 */
class FooController extends AppController {
    var $components = array('RequestHandler');
    var $uses = '';
    var $helpers = array('Text', 'Xml');
    function index() {
        $message = 'Testing';
        $this->set('message', $message);
        $this->RequestHandler->respondAs('xml');
        $this->viewPath .= '/xml';
        $this->layoutPath = 'xml';
    }
}

CakePHP: the rapid development php framework

Missing Controller

Error: FooController could not be found.

Error: Create the class FooController below in file: app\controllers\foo_controller.php

Strange thing is that (everyone can see) that controller text is loaded in the error page, but error shows that controller file is not found. I also tried to follow the tutorial on book.cakephp.org/view/477/The-Simple-Setup. But same error also occured here. Anyone can help? By the way I also changed the text of routes.php to work it with web webservices. Thanks

A: 

You have entered the URL http://localhost:81/cakephp/foo. Cake correctly interprets this to mean you are looking for the index action on the FooController. The error doesn't mean it has found the file, just that it has worked out what to look for but hasn't found it where it expects it to be.

The line: Error: Create the class FooController below in file: app\controllers\foo_controller.php tells you what should be there (and what, as a minimum, it should look like). Check that you have named the file correctly and that it located where the error says it should be.

Leo
Thanks! But I created the file foo_controller.php in app\controllers folder. That's why I'm surprised. Because at the top of the error page cakephp writes all the code of foo_controller.php and after the code it mention that foo_controller.php file is not find. If cakePhp didn't find the file then how it manage to read and write the text of it on error page? Hope you now understand the problem. Any help regarding to solve this issue. Or on creating the Rest Web services in cakephp 1.2 will be welcomed.Thanks
mas
Try entering something like ~/rubbishes/index and see what the error looks like.
Leo
Your call should be plural as should the name of the controller - foos
Leo