Cześć!
Chciałem pobawić się trochę w symfony, ale niestety poległem przy konfiguracji.
Mianowicie przez composera dodałem FOSRestController i JMSSerialize. Następnie przez
bin/console generate:bundle
wygenerowałem bundla.
Następnie w src/ApiBundle/Resources/config/routing.yml dodałem:
Api:
resource: "@api/Controller/ApiController.php"
prefix: /api/
type: rest
A w app/config/config.yml:
fos_rest:
body_listener: true
format_listener:
rules:
- { path: '^/', priorities: ['json'], fallback_format: json, prefer_extension: false }
param_fetcher_listener: true
view:
view_response_listener: 'force'
formats:
json: true
Plik src/ApiBundle/Controller/ApiController.php zawiera:
<?php
namespace ApiBundle\Controller;
use FOS\RestBundle\Controller\FOSRestController;
class ApiController extends FOSRestController {
public function optionsApiAction() {
}
public function getUserAction() {
$data = array(
'type' => 'asd',
'asd' => 'pbk',
);
$this->view($data, 200);
return $this->handleView($view);
}
}
Niestety ciągle dostaję komunikat:
Bundle "api" does not exist or it is not enabled. Maybe you forgot to add it in the registerBundles() method of your AppKernel.php file? in @Api/Controller/ApiController.php (which is being imported from "/var/www/html/api/src/ApiBundle/Resources/config/routing.yml"). Make sure the "api" bundle is correctly registered and loaded in the application kernel class. If the bundle is registered, make sure the bundle path "@Api/Controller/ApiController.php" is not empty.
Czy ktoś bardziej doświadczony z tym frameworkiem mógłby podpowiedzieć co robię źle?