I've installed Phalcon on my server Centos 7 with PHP-FPM 5.6
I'm following the basic instructions at https://docs.phalcon.io/en/latest/reference/tutorial.html and get stuck at the beginning:
Sometimes it displays the correct "Hello!" message, but I've refreshed the page several times and most of the time I get the following error:
Fatal error: Access to undeclared static property: Phalcon\Di::$_default in /var/www/vhosts/playerm8.com/httpdocs/public/index.php on line 20
My public/index.php looks like this:
<?php
use Phalcon\Loader;
use Phalcon\Mvc\View;
use Phalcon\Mvc\Application;
use Phalcon\Di\FactoryDefault;
use Phalcon\Mvc\Url as UrlProvider;
use Phalcon\Db\Adapter\Pdo\Mysql as DbAdapter;
try {
// Register an autoloader
$loader = new Loader();
$loader->registerDirs(array(
'../app/controllers/',
'../app/models/'
))->register();
// Create a DI
$di = new FactoryDefault()
;
// Setup the view component
$di->set('view', function () {
$view = new View();
$view->setViewsDir('../app/views/');
return $view;
});
// Setup a base URI so that all generated URIs include the "tutorial" folder
$di->set('url', function () {
$url = new UrlProvider();
$url->setBaseUri('/');
return $url;
});
// Handle the request
$application = new Application($di);
echo $application->handle()->getContent();
} catch (\Exception $e) {
echo "Exception: ", $e->getMessage();
}
And my apps/controllers/IndexController.php looks like this:
<?php
use Phalcon\Mvc\Controller;
class IndexController extends Controller
{
public function indexAction()
{
echo "<h1>Hello!</h1>";
}
}
Any help would be appreciated