1

I seem to get the 500 error when trying to query the database (mongodb) if I remove the query it display the view fine. From using the quick start guide and other online tutorials I carnt see that I am doing anything wrong.

Model - Posts.php

<?php

namespace app\models;

class Posts extends \lithium\data\Model {

}

Controller - PostsController.php

<?php
/**
 * Lithium: the most rad php framework
 *
 * @copyright     Copyright 2015, Union of RAD (http://union-of-rad.org)
 * @license       http://opensource.org/licenses/bsd-license.php The BSD License
 */

namespace app\controllers;

use app\models\Posts;

class PostsController extends \lithium\action\Controller {

    public function index() {

        $posts = Posts::find('all', array(
            'conditions' => array('author' => 'tom')
        ));

        return $this->render(array('layout' => false));
    }

}

?>

View - index.html.php

Contains some text no php as trying to get it working first.

Connor Brough
  • 579
  • 1
  • 9
  • 24

1 Answers1

0

Is it possible you don't have MongoDB installed? It's also possible this has something to do with mod_rewrite (AllowOverride comes to mind). Your best bet is to look at your logs.

The location of your logs depends on what you're using. If you're using Apache2 on Ubuntu, it would be located in /var/log/apache2.

Run this in your terminal while refreshing your page: tail -f /var/log/apache2/error.log where error.log is assumed to be the log file name. As you refresh your page, you should be able to see the error in your terminal.

Housni
  • 963
  • 1
  • 10
  • 23
  • I have Mongo DB installed and running. I am using Mac OS X so the commands didn't work unfortunately. The website only stops working as soon as a model is declared. – Connor Brough Feb 15 '16 at 08:24
  • It's really difficult to say unless you can post more information. Perhaps find out where your logs lay and show us the relevant lines from it? – Housni Feb 15 '16 at 12:54
  • located the log which is in /private/var/log/apache2/error.log however carnt see any errors relating to mongo or server 500 – Connor Brough Feb 15 '16 at 13:12
  • Which version of PHP mongodb driver are you using? Could you try if you can instantiate the MongoClient class (for legacy version) or MongoDB\Driver\Manager (newer version) directly? – blubear Feb 16 '16 at 03:53