Question

I'm following the quickstart guide for Lithium: http://li3.me/docs/manual/quickstart

I created my posts Model in /var/www/my_app/app/models/Posts.php

<?php

namespace app\models;

class Posts extends \lithium\data\Model {
}

?>

I created my posts Controller in /var/www/my_app/app/controllers/PostsController.php

<?php

namespace app\controllers;

class PostsController extends \lithium\action\Controller {

    public function index() {
            return array('foo' => 'bar', 'title' => 'Posts');
    }
}

?>

And I created my View in /var/www/my_app/app/views/posts/index.html.php

Lithium is less dense than <?=$foo;?>ium.

The quickstart guide then says that I should be able to view my posts index page by going to

http://localhost/my_app/posts

but I get a

Not Found

The requested URL /my_app/posts was not found on this server.

However, if I go to just

http://localhost/my_app 

the default home page that comes with Lithium is displayed.

So I tried fixing the problem by adding this line to my /var/www/my_app/config/routes.php file:

Router::connect('/posts', 'Posts::index');

But I get the same Not Found error?

Was it helpful?

Solution

You need to make sure that mod_rewrite is installed and enabled in your Apache.

Also check that the .htaccess file is present and allow_override is properly set for the virtualHost, otherwise .htaccess files will be ignored.

For further information, check the troubleshooting section in the documentation

OTHER TIPS

A little bit further in the Routing documentation, the parameters of the Router::connect() method are explained more fully. The portion after the :: should be the name of the action called by the route; in your case index (or perhaps nothing, if there's a default set for the indexAction; not familiar with Lithium). You derive the "name" by removing the suffix Action from your Controller's method name. I suggest exploring the Routing documentation more fully to save yourself headaches in the future.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top