Canser Yanbakan
Canser Yanbakan

Reputation: 3870

Symfony2 Bundle working as a service but not working when calling as a route

When i call my bundle as a service, everything working fine.

When i give a route to my bundle's controller, __contstruct stops working and the variables coming from config.yml file reasoning this.

These are warnings, but i need to get work to set my variables.

Warning: Missing argument 1 for ATL15\GoogleAnalyticsBundle\Controller\GoogleAnalyticsController::__construct(), called in /var/www/vsy-bio/app/cache/dev/jms_diextra/controller_injectors/ATL15GoogleAnalyticsBundleControllerGoogleAnalyticsController.php on line 13 and defined in /var/www/vsy-bio/src/ATL15/GoogleAnalyticsBundle/Controller/GoogleAnalyticsController.php on line 22

Upvotes: 1

Views: 60

Answers (1)

Nicolai Fröhlich
Nicolai Fröhlich

Reputation: 52513

You need to call your controller as a service aswell in your routing like this:

hello:
    pattern:      /hello
    defaults:     { _controller: acme.hello.controller:indexAction }

See the documentation chapter How to define Controllers as Services.

Upvotes: 1

Related Questions