php - lost current local language after login and after logout -
i can switch language of web site correctly when log in, lost current language in url. exemple before login http://test.bu/app_dev.php/en/admin/slideshow/ , after login have http://test.bu/app_dev.php/fr/admin/slideshow/ symfony2.7 takes locale: fr. use fosuserbundle. ggogled find can use bundles fix think can resolve editing confinguration. after login redirect web site default_target_path: slideshow_index this
app_slideshow: resource: "@appbundle/resources/config/routing/slideshow.yml" prefix: /{_locale}/admin/slideshow
this config.yml imports: - { resource: parameters.yml } - { resource: security.yml } - { resource: services.yml } # put parameters here don't need change on each machine app deployed # https://symfony.com/doc/current/best_practices/configuration.html#application-related-configuration parameters: locale: fr framework: #esi: ~ translator: { fallback: %locale% } secret: '%secret%' router: resource: '%kernel.root_dir%/config/routing.yml' strict_requirements: ~ form: ~ csrf_protection: ~ validation: { enable_annotations: true } #serializer: { enable_annotations: true } templating: engines: ['twig'] default_locale: '%locale%' trusted_hosts: ~ trusted_proxies: ~ session: # handler_id set null use default session handler php.ini handler_id: ~ fragments: ~ http_method_override: true # twig configuration twig: debug: '%kernel.debug%' strict_variables: '%kernel.debug%' # doctrine configuration doctrine: dbal: driver: pdo_mysql host: '%database_host%' port: '%database_port%' dbname: '%database_name%' user: '%database_user%' password: '%database_password%' charset: utf8 # if using pdo_sqlite database driver: # 1. add path in parameters.yml # e.g. database_path: '%kernel.root_dir%/data/data.db3' # 2. uncomment database_path in parameters.yml.dist # 3. uncomment next line: #path: '%database_path%' orm: auto_generate_proxy_classes: '%kernel.debug%' naming_strategy: doctrine.orm.naming_strategy.underscore auto_mapping: true # swiftmailer configuration swiftmailer: transport: '%mailer_transport%' host: '%mailer_host%' username: '%mailer_user%' password: '%mailer_password%' spool: { type: memory } # app/config/config.yml fos_user: db_driver: orm # other valid values 'mongodb' , 'couchdb' firewall_name: main user_class: gold\userbundle\entity\user from_email: address: "%mailer_user%" sender_name: "%mailer_user%" stackoverflow
link of jms routing bundle https://github.com/schmittjoh/jmsi18nroutingbundle
but before install please @ short video tutorial. tutorial helped me lot understand problem having between fos user bundle , locale in url.
if don't want install jms routing bundle composer.json file can install command php composer.phar require jms/i18n-routing-bundle "dev-master"
here config:
jms_i18n_routing: default_locale: "%locale%" locales: ["fr", "en"] strategy: prefix_except_default
security.yml:
firewalls: main: pattern: ^/ form_login: provider: fos_userbundle csrf_token_generator: security.csrf.token_manager require_previous_session: false login_path: fos_user_security_login check_path: fos_user_security_check default_target_path: your_route_name_homepage logout: path: fos_user_security_logout target: your_route_name_homepage anonymous: true access_control: - { path: ^/login$, role: is_authenticated_anonymously && !is_authenticaded_fully } - { path: ^/register, role: is_authenticated_anonymously && !is_authenticaded_fully } - { path: ^/resetting, role: is_authenticated_anonymously } - { path: ^/admin/, role: role_admin }
after having installed jms routing bundle. try execute commande debug/router
(symfony 3) , watch routes names , prefix.
Comments
Post a Comment