Reputation: 139
I'm on windows 10 server edition x64 Architecture using Phalcon 4.0.6, php-7.4.7 with xampp & psr-1.0.0. Following example from: 'https://docs.phalcon.io/4.0/en/application'. I'm unable to load controller output / views output without any error message it just showing blank white page & unable to find what i am doing wrong.
[File Structure]
[index.php]
<?php
declare(strict_types=1);
error_reporting(1);
use Phalcon\Mvc\Router;
use Phalcon\Loader;
use Phalcon\Mvc\View;
use Phalcon\Mvc\Application;
use Phalcon\Di\FactoryDefault;
use Phalcon\Mvc\Dispatcher;
$di = new FactoryDefault();
$loader = new Loader();
$loader->registerNamespaces(
array(
'Single\Controllers' => '../app/Controllers',
)
);
$loader->register();
$di->set('router', function(){
$router = new Router(FALSE);
$router->setDefaultNamespace('Single\Controllers');
return $router;
});
// Registering the view component
$di->set('view',function () {
$view = new View();
$view->setViewsDir('../app/views/');
return $view;
}
);
$application = new Application($di);
try {
$response = $application->handle(
$_SERVER["REQUEST_URI"]
);
$response->send();
} catch (\Exception $e) {
echo 'Exception: ', $e->getMessage();
}
[IndexController.php]
<?php
declare(strict_types=1);
namespace Single\Controllers;
use Phalcon\Mvc\Controller;
/**
* Class IndexController
*
* @property View $view
*/
class IndexController extends Controller
{
/**
* Welcome and user list
*/
public function indexAction()
{
echo '<h1>Congratulations, you are Phlying with Phalcon!</h1>';
}
}
Upvotes: 2
Views: 114