Quantcast
Channel: Active questions tagged symfony4 - Stack Overflow
Viewing all articles
Browse latest Browse all 3925

I've defined a bundle Controller and Routing, but I get "Error: the controller does neither exist as service nor as class"

$
0
0

I have created a controller class under a module directory in Symfony 4. My bundle's routing file references it. My root's routing file includes the bundle's routing file.

However I get an error 500, "Error: the controller does neither exist as service nor as class".

Why?

root/src/MyBundle/Resources/config/routing.YML

route_name:  path: /test3  controller: MyBundle\Controller\ExportCsvController::exportProductInCsv  options:    expose: true

root/config/routes/my_custom_routes.YML

route_name:      resource: "@MyBundle/Resources/config/routing.yml"      prefix:   /

root/src/MyBundle/Controller/ExportCsvController.PHP

<?phpnamespace MyBundle\Controller;use Symfony\Bundle\FrameworkBundle\Controller\Controller;use Symfony\Component\HttpFoundation\Response;use Symfony\Component\Routing\Annotation\Route;class ExportCsvController extends Controller{    public function exportProductInCsv(): Response    {        return new Response('<html><body>test</body></html>'        );    }}

Viewing all articles
Browse latest Browse all 3925

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>