We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

Why I can't connect to Mysql with cmoore4/phalcon-rest repo?

Hi everyone, I've used Phalcon micro for a couple of months, and now I want to switch to something more RESTful, and I found this repo https://github.com/cmoore4/phalcon-rest

  • I've declared database parameters in config.ini

[database] adapter = Mysql host = localhost username = test password = test name = test

  • I've set the di to connect to db

$di->set('db', function() use ($config) { $dbclass = 'Phalcon\Db\Adapter\Pdo\' . $config->database->adapter; return new $dbclass(array( "host" => $config->database->host, "username" => $config->database->username, "password" => $config->database->password, "dbname" => $config->database->name )); });

  • Class Princesses.php in is models folder

  • When I tried to add this line

$princesses = Princesses::find();

in the ExampleController.php, I got the blank page when going to host/v1/example. When I removed that line, everything is fine.

What am I doing wrong?

Thank you very much. Any help is appreciated!



Do you get an error 500 ? have a look at apache's log:

tail -f /var/log/apache2/error.log