Closed maykino closed 5 years ago
Can you show the exact configuration that you used when running into both of these issues?
Hello! I have the same error:
// Clearing the cache for the dev environment with debug true
In FileLoader.php line 168:
[Semantical Error] Couldn't find constant FOS\RestBundle\Util\Codes::HTTP_OK, method ArcaSolutions\ApiBundle\C
ontroller\DefaultController::getHomeAction() in C:\xampp\htdocs\test-symfony\src\ArcaSolutions\ApiBundle/Resou
rces/config/routing.yml (which is being imported from "C:\xampp\htdocs\test-symfony/app/config/routing.yml").
Make sure there is a loader supporting the "rest" type.
In AnnotationException.php line 54:
[Semantical Error] Couldn't find constant FOS\RestBundle\Util\Codes::HTTP_OK, method ArcaSolutions\ApiBundle\C
ontroller\DefaultController::getHomeAction().
my configuration:
fos_rest:
param_fetcher_listener: true
body_listener: true
format_listener:
rules:
- { path: ^/api, priorities: ['json', 'html', '*/*'], fallback_format: json, prefer_extension: true }
- { path: ^/, stop: true }
body_converter:
enabled: true
validate: true
view:
view_response_listener: 'force'
formats:
json: true
xml: false
templating_formats:
html: true
exception:
codes:
'Symfony\Component\Routing\Exception\ResourceNotFoundException': 404
'Doctrine\ORM\OptimisticLockException': HTTP_CONFLICT
messages:
'Symfony\Component\Routing\Exception\ResourceNotFoundException': true
'Symfony\Component\HttpKernel\Exception\HttpException': true
enabled: true
access_denied_listener:
json: true
disable_csrf_role: ROLE_API
Can you show the code of your DefaultController
class?
¿Puedes mostrar el código de tu
DefaultController
clase? My controller's code
The error is triggered by the usage of the @ApiDoc
annotation. Which version of FOSRestBundle do you use?
El error se desencadena por el uso de la
@ApiDoc
anotación. ¿Qué versión de FOSRestBundle usas?
-version "friendsofsymfony/jsrouting-bundle": "^2.2", "friendsofsymfony/oauth-server-bundle": "^1.6", "friendsofsymfony/rest-bundle": "^2.4", "nelmio/api-doc-bundle": "^2.13",
The FOS\RestBundle\Util\Codes
class doesn't exist in FOSRestBundle 2.x anymore. You will need to use another class that provides HTTP status code constants.
ok ready now I have this error on request:
Fatal error: Uncaught exception 'Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException' with message 'You have requested a non-existent service "request". Did you mean one of these: "fos_rest.request.param_fetcher", "fos_rest.request.param_fetcher.reader", "monolog.logger.request", "nelmio_api_doc.event_listener.request", "request_stack", "router.request_context", "validate_request_listener", "argument_resolver.request", "argument_resolver.request_attribute", "security.request_matcher.x1icpav", "security.request_matcher.zfhj2lw"?'
please help.
I am sorry, but this is far beyond what we can support in the issue tracker. The request
service has been removed in Symfony 3.0. I suggest to seek for help on the Symfony Slack team or on StackOverflow (see Https://symfony.com/support).
Closing as not actionable.
I had to remove these red lines Even though symfony documentation gives that bit https://symfony.com/doc/master/bundles/FOSRestBundle/configuration-reference.html
I'm trying to set up an API by following the examples from the documentation and default config from the symfony page:
https://symfony.com/doc/master/bundles/FOSRestBundle/configuration-reference.html
When trying to access the application I get the following errors right away:
Invalid HTTP code in fos_rest.exception.codes, see Symfony\Component\HttpFoundation\Response for all valid codes.
When removed the exception section there is another one:
The service "fos_rest.decoder_provider" has a dependency on a non-existent service "".
Since it's a default configuration I assumed that it would work out of the box. It's a hassle for a developer to now find out what each of the config option mean and provide the expected values.