简体   繁体   中英

Phalcon Annotations Router throws exception regarding the DI

I'm trying to use annotations router but I'm facing the below exception

A dependency injection container is required to access the 'annotations' service

You can review my settings and configurations below

Setting up annotations router in public/index.php

$di->set('router', function () {
    $router = new \Phalcon\Mvc\Router\Annotations(false);
    $router->addResource('User');
    return $router;
});

My UserController.php

/**
 * @RoutePrefix("/user")
 */
class UserController extends \Phalcon\Mvc\Controller
{
    /**
     * @Get("/signin")
     */
    public function signinAction()
    {
    }
}

When point my browser to domain/user/signin I face the mentioned exception. I would appreciate any kind of help as I'm new to the world of Phalcon.

添加以下调用即可解决问题。

$router->setUriSource(\Phalcon\Mvc\Router::URI_SOURCE_SERVER_REQUEST_URI);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM