InvalidConfigurationException invalid success handler Symfony - symfony

I want to specify change password success handler in my configuration file so that it will route to path which I've specified
I am doing this in my security.yml file under security.firewalls.main
change_password:
success_handler: redirect.after.change_password
where redirect.after.change_password is my service class in which I've specify it where to route.
it shows error :
Unrecognized option "change_password" under "security.firewalls.main"
where and how should it be mentioned so that it'll work properly.
Thanking in an anticipation

Related

Symfony (3.4.2) - Error: Controller "fos_rest.exception.twig_controller" cannot be fetched from the container because it is private

I'm on an api project using FOSRestBundle on Symfony 3.4 and have some error when I want to use my own error messages.
It says me:
Controller "fos_rest.exception.twig_controller" cannot be fetched from the container because it is private. Did you forget to tag the service with "controller.service_arguments"
I'm stuck on this error, I think a config is missing but I don't understand which one...
Thanks
I found the solution:
Add to your config.yml, in fos_rest:
fos_rest:
//
exception:
//
exception_controller: 'fos_rest.exception.controller:showAction'

Symfony log deprecated warning on new file

I want to log only the deprecated warnings to a new file. But I can't see how to achieve that with monolog. Is there a custom configuration?
Thanks in advance!
All Deprecated Message are logged As INFO level, php Channels so if You try this configuration All deprecation message will be logged in one file
monolog:
handlers:
security:
level: INFO
type: stream
path: '%kernel.logs_dir%/deprecated.log'
channels: [php]

Add optional _locale to routes

I'd like to prefix all my urls by an optional _locale. BTW, I'm handling fr and en.
The point is, when _locale is given I'll use it thanks to symfony Symfony\Component\HttpKernel\EventListener\LocaleListener::onKernelRequest, if not I'll use the locale saved in the database thanks to my own listener (priority: 15) which runs immediately after the previous one.
What I've tried so far is the following:
app/config/routing.yml
entrypoint:
resource: 'locale_prefixed_routing.yml'
prefix: /{_locale}
And locale_prefixed_routing.yml imports bundles routings.
/fr/url/example works but /url/example does not and returns 404 page.
How do I tell symfony to use the locale in the url, if does not exist use the one in the database?
I suppose your routes are defined like this in your locale_prefixed_routing.yml :
my_route:
path: /
defaults:
Actually routes like /url/example without any locale are not defined in your routing because you ask to prefix all the routes loaded in locale_prefixed_routing.yml by the locale. So it is normal to get an error when requesting such a route without locale.
You can try to make another routing file named non_localized_routing.yml containing the same routes except that you will use specific defaults.
Example :
route_example:
path: /url/example
defaults:
_controller: FrameworkBundle:Redirect:urlRedirect
path: /{_locale}/url/example
permanent: true
Tell me if it permits you to get rid of your problem, I haven't test it yet.
For me it sounds weird to store the locale in the database when the locale is not provided by the user. You can simply add a default one:
framework:
default_locale: en

FOSRestBundle doesn't load routes

I'm trying to make a REST API using FOSRestBundle and I'm getting some errors due to routing. This is how I test the routes. With this code in routing.yml I get this error:
1st test:
routing.yml
device_id_api:
type: rest
path: /device/{imei}/getid
resource: "Device\DeviceBundle\Controller\DeviceRestController"
Error
FileLoaderLoadException: Cannot import resource
"/var/www/html/src/Device/DeviceBundle/Resources/config/routing.yml"
from "/var/www/html/app/config/routing.yml". (The routing
file
"/var/www/html/src/Device/DeviceBundle/Resources/config/routing.yml"
must not specify both the "resource" key and the "path" key for
"device_id_api". Choose between an import and a route definition.)
2nd test:
`routing.yml
device_id_api:
type: rest
prefix: /device/{imei}/getid
resource: "TaxiBooking\Device\DeviceBundle\Controller\DeviceRestController"
Error
No route found for "GET /device/2147483647/getid"
What is wrong on that routes? I clear the cache several times and the error remains. Any help?
The prefix /device/{imei}/getid is exactly that, a prefix.
The actions in your controller like (for, example) getUsersAction will then be added to this prefix to create paths like /device/{imei}/getid/users [GET].
It's all explained in the docs minus your usage of the prefix, but that just means that it added to the start of the path auto-generated by the RoutingLoader.

Symfony2 CRUD routing Failed

After executing the following command for CRUD generation:
php app/console generate:doctrine:crud --entity=AcmeDemoBundle:Users --format=yml
i get error for automatic routing update by CRUD for each entity.
Confirm automatic update of the Routing [yes]? yes
Importing the CRUD routes: FAILED
The command was not able to configure everything automatically.
You must do the following changes manually.
- Import the bundle's routing resource in the bundle routing file
(C:\wamp\www\symfony\src\Acme\DemoBundle/Resources/config/routing.yml).
AcmeDemoBundle_categories:
resource: "#AcmeDemoBundle/Resources/config/routing/categories.yml"
prefix: /categories
I also tried creating a new bundle but still gets same error. So everytime i add the above code in routing file /src/Acme/DemoBundle/Resources/config/routing.yml
Can someone please suggest what i am missing?
I get the same thing, not sure how to get the generation to work right but it wants you to add that code to your main routing.yml file so it can link the generated routes:
AcmeDemoBundle_categories:
resource: "#AcmeDemoBundle/Resources/config/routing/categories.yml"
prefix: /categories

Resources