I'm using symfony 3.1.7 and I have problems with inject services into a controller, my english is bad I believe that it is better if I show all the code.
The error:
Type error: Argument 1 passed to ...Bundle\Controller\AdminController::__construct() must implement interface Symfony\Component\DependencyInjection\ContainerInterface, none given, called in /......./project/var/cache/dev/classes.php on line 2512
This is my code:
GenericRestController
namespace MyCoreBundle\Controller;
use Symfony\Component\DependencyInjection\ContainerInterface as Container;
use MyCoreBundle\Handler\GenericRestHandlerInterface as Generic;
/** other uses like FOSRestController **/
/**
* Class GenericRestController
*/
abstract class GenericRestController extends FOSRestController
{
protected $handler;
protected $container;
public function __construct(Container $container,Generic $handler)
{
$this->container = $container;
$this->handler = $handler;
}
/** other methods like get, post, put, etc **/
}
AdminController
namespace ...Bundle\Controller;
use MyCoreBundle\Controller\GenericRestController;
class AdminController extends GenericRestController
{
}
RESOLVED
The solution was change the routes as Cerad says.
Oficial documentation
services.yml
services:
app.hello_controller:
class: AppBundle\Controller\HelloController
routing.yml
hello:
path: /hello
defaults: { _controller: app.hello_controller:indexAction }
Thanks mtaqi and Cerad
php app/console container:debuglists shows? - Muhammad Taqi