Hello, I have encountered wierd behavior which I can't really describe, perhaps someone will be kind enough to shed some light on it.
Scenario 1 (working, note: the logic is in one file)
bootstrap.php
<?php
use Phalcon\Mvc\Application,
Phalcon\Loader;
try {
//Register an autoloader
$loader = new Loader();
//Namespaces
$loader->registerNamespaces(array(
'Phalcon' => __DIR__ . '/../vendor/incubator/Library/Phalcon',
'CoreBundle\Models' => __DIR__ . '/../app/bundles/CoreBundle/models/',
));
$loader->register();
//Twig
require "../vendor/twig/twig/lib/Twig/Autoloader.php";
Twig_Autoloader::register();
Scenario 2 (Not working, note: the logic is seperated into two files (Bootstrap.php and loader.php)
bootstrap.php
<?php
use Phalcon\Mvc\Application,
Phalcon\Loader;
try {
include __DIR__ . "/../app/config/loader.php";
//Twig
require "../vendor/twig/twig/lib/Twig/Autoloader.php";
Twig_Autoloader::register();
loader.php
<?php
$loader = new \Phalcon\Loader();
$loader->registerNamespaces(array(
'Phalcon' => __DIR__ . '/../vendor/incubator/Library/Phalcon',
'CoreBundle\Models' => __DIR__ . '/../app/bundles/CoreBundle/models/',
))->register();
What I get is "Service 'Phalcon\Mvc\View\Engine\Twig' was not found in the dependency injection container".
Scenario 3 (Not working, note: logic is seperate into two files but register happens in bootstrap)
bootstrap.php
<?php
use Phalcon\Mvc\Application,
Phalcon\Loader;
try {
$loader = include __DIR__ . "/../app/config/loader.php";
$loader->register();
//Twig
require "../vendor/twig/twig/lib/Twig/Autoloader.php";
Twig_Autoloader::register();
loader.php
<?php
$loader = new \Phalcon\Loader();
$loader->registerNamespaces(array(
'Phalcon' => __DIR__ . '/../vendor/incubator/Library/Phalcon',
'CoreBundle\Models' => __DIR__ . '/../app/bundles/CoreBundle/models/',
));
return $loader;
What I get is "Service 'Phalcon\Mvc\View\Engine\Twig' was not found in the dependency injection container".
Why is that happening, why is Scenario 2 or 3 not working?