-
-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error parsing annotations router #1040
Comments
Phalcon\Mvc\Router\Annotations has addResource method. |
Guy, I'am not looking for resolving this issue, I'am just post Bug for fixing it. Do you understand it? |
@3axap4eHko could you please post the code that reproduces the bug? |
No, I could not post the code now. Just repoduced by redefining $di->set('annotations', function()
{
$annotations = new Phalcon\Annotations\Adapter\Files(['annotationsDir' => __DIR__ . '/tmp/']);
return $annotations;
});
$di->set('router', function()
{
$router = new Phalcon\Mvc\Router\Annotations();
$router->addResource('Test_Admin');
return $router;
}); |
Mistake is in the parsing handler of router resource from annotation with |
With the code you gave I am unable to reproduce the issue. test_admincontroller.php is correctly created, its contents is as follows: <?php return Phalcon\Annotations\Reflection::__set_state(array(
'_reflectionData' =>
array (
'class' =>
array (
0 =>
array (
'type' => 300,
'name' => 'RoutePrefix',
'arguments' =>
array (
0 =>
array (
'expr' =>
array (
'type' => 303,
'value' => '/admin',
),
),
),
'file' => '/path/to/test/AdminController.php',
'line' => 4,
),
),
'methods' =>
array (
'indexAction' =>
array (
0 =>
array (
'type' => 300,
'name' => 'Get',
'arguments' =>
array (
0 =>
array (
'expr' =>
array (
'type' => 303,
'value' => '/',
),
),
),
'file' => '/path/to/test/AdminController.php',
'line' => 9,
),
),
),
),
'_classAnnotations' => NULL,
'_methodAnnotations' => NULL,
'_propertyAnnotations' => NULL,
)); On subsequent requests the cache is rad and the correct file gets included. Could you please provide a complete reproducible example of the bug? |
Are you OS is Linux? |
yes, Ubuntu |
structure:
/public/index.php <?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
use Phalcon\DI\FactoryDefault;
if (!defined('APP_DIR'))
{
define('APP_DIR', dirname(__DIR__));
}
$loader = new Phalcon\Loader();
$loader->registerNamespaces([
'App' => APP_DIR . '/src/App'
])->register();
$di = new FactoryDefault();
$di->set('annotations', function()
{
$annotations = new Phalcon\Annotations\Adapter\Files(array(
'annotationsDir' => APP_DIR . '/cache/annotations/'
));
return $annotations;
});
$di->set('router', function()
{
$router = new Phalcon\Mvc\Router\Annotations(false);
$router->setUriSource(Phalcon\Mvc\Router::URI_SOURCE_SERVER_REQUEST_URI);
$router->addResource('App\Controller\Test_Admin');
return $router;
});
$di->set('dispatcher', function()
{
$dispatcher = new Phalcon\Mvc\Dispatcher();
$dispatcher->setDefaultNamespace('App\Controller');
return $dispatcher;
});
$di->set('view', function()
{
$view = new Phalcon\Mvc\View();
$view->setViewsDir(APP_DIR . '/view');
return $view;
});
$application = new \Phalcon\Mvc\Application($di);
echo $application->handle()->getContent(); /src/App/Controller/Admin_TestController.php <?php
namespace App\Controller;
use Phalcon\Mvc\Controller,
Phalcon\Tag;
/**
* @RoutePrefix("/")
*/
class Test_AdminController extends Controller
{
/**
* @Get("/")
*/
public function testAction()
{
}
} Error on more than one times reload page, when annotations taked from file
|
OK trying |
This one does not work at all: Fatal error: Uncaught exception 'ReflectionException' with message 'Class App\Controller\Test_AdminController does not exist' in /home/vladimir/workspace/cphalcon/1040/public/index.php:60 This happens on the very first request. |
The file is probably named /src/App/Controller/Test_AdminController.php, not /src/App/Controller/Admin_TestController.php? |
OK, confirmed. |
Have a nice day) |
I'am called my controller:
App\Controller\Test_AdminController
then add resource to loader:
$router->addResource('App\Controller\Test_Admin');
after first load all right, but next time I'am all time getting error:
App\Controller\Test_adminController handler class cannot be loaded
why Test_AdminController is Test_adminController after first reload?
OS: Ubuntu
This occurs when using
Phalcon\Annotations\Adapter\Files
When Annotations Adapter is
Phalcon\Annotations\Adapter\Memory
- all rightThe text was updated successfully, but these errors were encountered: