I am building an api bundle for sulu but when im configuring routes to my controller i get the error 'The controller for URI "/ovio" is not callable: Controller "ovio.controller" does neither exist as service nor as class.'
What am i doing wrong here?
# sulu application -> config/routes_websites.yaml
ovio_bundle:
path: /ovio
defaults:
_controller: ovio.controller
// My Bundle -> OvioController.php
namespace DigitalWeb\Bundle\OvioBundle\Controller;
use DigitalWeb\Bundle\OvioBundle\Interface\OvioInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\HttpFoundation\Request;
#[Route('/ovio', name: 'api_')]
class ProjectController extends AbstractController
{
#[Route('/api', name: 'api')]
public function index(OvioInterface $OvioInterface): JsonResponse
{
$response = $OvioInterface->api_call($this->getParameter('api_key'));
$json = new JsonResponse();
return $json->fromJsonString($response);
}
#[Route('/api/{license}', name: 'api_license')]
public function indexVehicle(OvioInterface $OvioInterface, $license): JsonResponse
{
$request = Request::createFromGlobals();
$response = $OvioInterface->api_call($this->getParameter('api_key'), $license, $request->query);
$json = new JsonResponse();
return $json->fromJsonString($response);
}
}
<!-- My Bundle -> Resources/config/services.xml -->
<?xml version="1.0" encoding="UTF-8" ?>
<container xmlns="http://symfony.com/schema/dic/services"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://symfony.com/schema/dic/services
http://symfony.com/schema/dic/services/services-1.0.xsd">
<services>
<service id="ovio.controller" class="DigitalWeb\Bundle\OvioBundle\Controller\OvioController" autowire="true"
public="true">
<argument type="service" id="fos_rest.view_handler.default"/>
<tag name="ovio.controller"/>
<tag name="controller.service_arguments"/>
<tag name="container.service_subscriber"/>
<!-- <tag name="sulu.context" context="website"/> -->
</service>
</services>
</container>