$di = new Phalcon\DI\FactoryDefault();
$di->setShared(
'db',
function () {
$connection = new Phalcon\Db\Adapter\Pdo\Mysql(
[
'host' => 'localhost',
'port' => 3306,
'dbname' => 'phalcon_test',
'username' => 'root',
'charset' => 'UTF8',
]
);
return $connection;
}
);
$di->set(
'view',
function () {
$view = new \Phalcon\Mvc\View();
$view->setViewsDir('views');
$view->registerEngines(
[
'.volt' => function ($view, $di) {
$volt = new Volt($view, $di);
$options = [
'compiledPath' => 'cache',
];
$options += ['compileAlways' => true];
$volt->setOptions($options);
return $volt;
},
]
);
return $view;
}
);
$di->set(
'router',
function () {
$router = new \Phalcon\Mvc\Router();
$router->add('/index', ['controller' => 'index', 'action' => 'index']);
$router->add('/test', ['controller' => 'index', 'action' => 'test']);
return $router;
}
);
class Albums extends Model
{
}
class IndexController extends \Phalcon\Mvc\Controller
{
public function indexAction()
{
$test = Albums::find();
$this->view->setVar('albums', $test);
var_dump($test);
}
public function testAction()
{
}
}
$app = new \Phalcon\Mvc\Application($di);
echo $app->handle()->getContent();
When im accessing /test
I don't have issue like your, i don't have any result from index action. Post script please to reproduce a problem. Or just check logs as i wrote.