Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

Annotations router

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

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

My UserController.php

<?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.



997
Accepted
answer

I found the answer! Adding the following invocation fixed my problem.

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