Symfony2 FosUserBundle is loosing session - php

I am using FosUserBundle to register and authenticate users in my website. But i am having troubles with it cause user session is loosen very soon. Sometimes 5 minutes, sometimes 10 minutes, and then user is redirected to the login form again, causing many users to left my website.
This is what i currently have in my project:
composer.json
{"require": {
"php": ">=5.3.3",
"symfony/symfony": "2.6.*",
"doctrine/orm": "~2.2,>=2.2.3,<2.5",
"doctrine/dbal": "<2.5",
"doctrine/doctrine-bundle": "~1.2",
"twig/extensions": "~1.0",
"symfony/assetic-bundle": "~2.3",
"symfony/swiftmailer-bundle": "~2.3",
"symfony/monolog-bundle": "~2.4",
"symfony/yaml": "2.7.*#dev",
"symfony/filesystem": "~2.6",
"sensio/distribution-bundle": "~3.0,>=3.0.12",
"sensio/framework-extra-bundle": "~3.0,>=3.0.2",
"incenteev/composer-parameter-handler": "~2.0",
"friendsofsymfony/user-bundle": "~2.0#dev",
"friendsofsymfony/jsrouting-bundle": "#stable",
"knplabs/knp-snappy-bundle": "dev-master",
"jms/serializer-bundle": "0.13.*"
},
"require-dev": {
"sensio/generator-bundle": "~2.3"
}
}
config.yml
imports:
- { resource: parameters.yml }
- { resource: security.yml }
- { resource: "#MoovityUserBundle/Resources/config/services.yml" }
- { resource: "#MoovityBackendBundle/Resources/config/services.yml" }
framework:
#esi: ~
translator: { fallback: "%locale%" }
secret: "%secret%"
router:
resource: "%kernel.root_dir%/config/routing.yml"
strict_requirements: ~
form: ~
csrf_protection: ~
validation: { enable_annotations: true }
templating:
engines: ['twig']
#assets_version: SomeVersionScheme
default_locale: "%locale%"
trusted_hosts: ~
trusted_proxies: ~
session:
# handler_id set to null will use default session handler from php.ini
handler_id: ~
cookie_lifetime: 0
gc_maxlifetime: 14400
fragments: ~
http_method_override: true
# translator: ~
# Twig Configuration
twig:
debug: "%kernel.debug%"
strict_variables: "%kernel.debug%"
# Assetic Configuration
assetic:
debug: "%kernel.debug%"
use_controller: false
bundles: [ MoovityBackendBundle ]
#java: /usr/bin/java
filters:
cssrewrite: ~
#closure:
# jar: "%kernel.root_dir%/Resources/java/compiler.jar"
#yui_css:
# jar: "%kernel.root_dir%/Resources/java/yuicompressor-2.4.7.jar"
# Doctrine Configuration
doctrine:
dbal:
driver: "%database_driver%"
host: "%database_host%"
port: "%database_port%"
dbname: "%database_name%"
user: "%database_user%"
password: "%database_password%"
charset: UTF8
# if using pdo_sqlite as your database driver, add the path in parameters.yml
# e.g. database_path: "%kernel.root_dir%/data/data.db3"
# path: "%database_path%"
orm:
auto_generate_proxy_classes: "%kernel.debug%"
auto_mapping: true
# Swiftmailer Configuration
swiftmailer:
transport: "%mailer_transport%"
host: "%mailer_host%"
username: "%mailer_user%"
password: "%mailer_password%"
spool: { type: memory }
fos_user:
db_driver: orm
firewall_name: main
user_class: Moovity\UserBundle\Entity\User
registration:
confirmation:
enabled: true
from_email:
address: noreply#mywebsite.com
sender_name: mywebsite
template: MoovityBackendBundle:Mail:mail_fos_user_register_template.html.twig
# template: FOSUserBundle:Registration:email.html.twig
form:
type: moovity_user_registration
resetting:
email:
from_email:
address: resetpass#mywensite.com
sender_name: My Website Reset Password
template: FOSUserBundle:Resetting:email.html.twig
form:
type: moovity_user_resetting
service:
mailer: fos_user.mailer.twig_swift
#fos_rest:
# routing_loader:
# default_format: json
security.yml
security:
encoders:
FOS\UserBundle\Model\UserInterface: sha512
role_hierarchy:
ROLE_ADMIN: ROLE_USER
ROLE_SUPER_ADMIN: ROLE_ADMIN
providers:
fos_userbundle:
# id: fos_user.user_provider.username
id: fos_user.user_provider.username_email
firewalls:
main:
pattern: ^/
form_login:
login_path: fos_user_registration_register
check_path: fos_user_security_check
provider: fos_userbundle
csrf_provider: form.csrf_provider
# always_use_default_target_path: true
# Redirección despues de loguear
default_target_path: moovity_backend_homepage
logout:
path: fos_user_security_logout
target: fos_user_registration_register
# target: fos_user_security_login
anonymous: true
security: true
remember_me:
key: 57361cdee0bb68f4e4b71f06b28fc07e
lifetime: 6000
What am i doing wrong?

Ok, i have noticed that fosuserbundle is loosing session with Symfony 2.6, so i switched to 2.3 and now it seems to be working.
Thank you very much.

I think the problem is the translation.
Got the same errors, try to remove the locale in your parameter and reset it with ~
Please post if it was the problem

Related

lost current local language after login and after logout

i can switch language of my web site correctly but when i log in, i lost my current language in the url. for exemple before login http://test.bu/app_dev.php/en/admin/slideshow/ and after login i have this http://test.bu/app_dev.php/fr/admin/slideshow/
symfony2.7 takes always locale: fr. i use FosUserBundle. i ggogled i find that i can use bundles to fix this but i think i can resolve this by editing confinguration.
after login i redirect the web site by the default_target_path: slideshow_index like this
app_slideshow:
resource: "#AppBundle/Resources/config/routing/slideshow.yml"
prefix: /{_locale}/admin/slideshow
this is my config.yml
imports:
- { resource: parameters.yml }
- { resource: security.yml }
- { resource: services.yml }
# Put parameters here that don't need to change on each machine where the app is 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 to null will use default session handler from 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 as your database driver:
# 1. add the 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 are 'mongodb' and 'couchdb'
firewall_name: main
user_class: Gold\UserBundle\Entity\User
from_email:
address: "%mailer_user%"
sender_name: "%mailer_user%"
thanks stackoverflow
Link of JMS routing bundle https://github.com/schmittjoh/JMSI18nRoutingBundle
But before you install it please look at this short video tutorial. This tutorial helped me a lot to understand the problem you are having between fos user bundle and the locale in url.
https://codereviewvideos.com/course/getting-started-with-fosuserbundle/video/translations-and-internationalisation-in-fosuserbundle
If you don't want to install jms routing bundle with your composer.json file you can install it with this command php composer.phar require jms/i18n-routing-bundle "dev-master"
Here is my 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 to execute the commande debug/router (symfony 3) and watch the routes names and prefix.
You can handle the locale detection/switch with JMSI18nRoutingBundle
Add the required bundles to composer.json:
"require": {
...
"jms/i18n-routing-bundle": "1.1.*",
"jms/translation-bundle": "1.1.*",
"friendsofsymfony/user-bundle": "1.3.*"
},
http://jmsyst.com/bundles/JMSI18nRoutingBundle/master/installation

api platform :LexikJWTAuthenticationBundle Failed to load private key

im using api paltform to create an authentification api following there tutorial.
https://api-platform.com/docs/core/jwt
i got this probleme:
Failed to load private key
"C:\wamp64\www\auth-api\app/../var/jwt/private.pem": 0906A068:PEM
routines:PEM_do_header:bad password read
security.yml
security:
encoders:
FOS\UserBundle\Model\UserInterface: bcrypt
providers:
fos_userbundle:
id: fos_user.user_provider.username
firewalls:
login:
pattern: ^/login
stateless: true
anonymous: true
provider: fos_userbundle
form_login:
check_path: /login_check
username_parameter: _username
password_parameter: _password
success_handler: lexik_jwt_authentication.handler.authentication_success
failure_handler: lexik_jwt_authentication.handler.authentication_failure
require_previous_session: false
main:
pattern: ^/
provider: fos_userbundle
stateless: true
anonymous: true
lexik_jwt: ~
dev:
pattern: ^/(_(profiler|wdt)|css|images|js)/
security: false
access_control:
- { path: ^/login, roles: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/, roles: IS_AUTHENTICATED_FULLY }
config.yml
imports:
- { resource: parameters.yml }
- { resource: security.yml }
- { resource: services.yml }
# Put parameters here that don't need to change on each machine where the
app is deployed
# http://symfony.com/doc/current/best_practices/configuration.html#application-related-configuration
parameters:
locale: en
framework:
#esi: ~
#translator: { fallbacks: ["%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:
# http://symfony.com/doc/current/reference/configuration/framework.html#handler-id
handler_id: session.handler.native_file
save_path: "%kernel.root_dir%/../var/sessions/%kernel.environment%"
fragments: ~
http_method_override: true
assets: ~
php_errors:
log: 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 as your database driver:
# 1. add the 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 }
# Nelmio CORS
nelmio_cors:
defaults:
allow_origin: ["%cors_allow_origin%"]
allow_methods: ["POST", "PUT", "GET", "DELETE", "OPTIONS"]
allow_headers: ["content-type", "authorization"]
expose_headers: ["link"]
max_age: 3600
paths:
'^/': ~
fos_user:
db_driver: orm # other valid values are 'mongodb' and 'couchdb'
firewall_name: main
user_class: AppBundle\Entity\User
from_email:
address: noreplay#noreplay.com
sender_name: noreplay
lexik_jwt_authentication:
private_key_path: '%jwt_private_key_path%'
public_key_path: '%jwt_public_key_path%'
pass_phrase: '%jwt_key_pass_phrase%'
token_ttl: '%jwt_token_ttl%'
routing.yml
api:
resource: '.'
type: 'api_platform'
app:
resource: '#AppBundle/Action/'
type: 'annotation'
fos_user:
resource: "#FOSUserBundle/Resources/config/routing/all.xml"
login_check:
path: /login_check
When you install LexikJWTAuthenticatioBundle you need to launch this command from your console
$ openssl genrsa -out var/jwt/private.pem -aes256 4096
$ openssl rsa -pubout -in var/jwt/private.pem -out var/jwt/public.pem
You need to insert a password and add It to your parameters.yml assgined to variable: jwt_key_pass_phrase
Like this:
jwt_key_pass_phrase: ''
You should look directly in the docs of LexikJWTAuthenticationBundle since this is not really linked to api-platform.
It may mean that the private key is wrong.

FOSUserBundle Authentication not working on production server

I am new to Symfony, and probably thats why i don't seem to be able to target where the certain bugs generate from.
A new problem popped up when i put my site on the production server, the FOSUserBundle Authentication doesn't seem to work
Note: This worked absolutely fine on localhost, but as soon as i put it on the distant server, it does not validate any user.
The web/config.php file recommends that i :
1) Install and enable the php_posix extension (used to colorize the CLI output).
2) Install and enable the intl extension (used for validators)
3) Install and enable a PHP accelerator like APC (highly recommended).
4) Set short_open_tag to off in php.ini*.
Could this cause problems in Authentication ?
my config.yml file
imports:
- { resource: parameters.yml }
- { resource: security.yml }
framework:
#esi: ~
translator: { fallback: "%locale%" }
translator: ~
secret: "%secret%"
router:
resource: "%kernel.root_dir%/config/routing.yml"
strict_requirements: ~
form: ~
csrf_protection: ~
validation: { enable_annotations: true }
templating:
engines: ['twig']
#assets_version: SomeVersionScheme
default_locale: "%locale%"
trusted_hosts: ~
trusted_proxies: ~
session:
# handler_id set to null will use default session handler from php.ini
handler_id: ~
fragments: ~
http_method_override: true
# Twig Configuration
twig:
debug: "%kernel.debug%"
strict_variables: "%kernel.debug%"
# Assetic Configuration
assetic:
debug: "%kernel.debug%"
use_controller: false
bundles: [ LesCouvertsBundle , LesRestaurantBundle , LesVirtualMarketBundle , LesShopBundle ]
#java: /usr/bin/java
filters:
cssrewrite: ~
#closure:
# jar: "%kernel.root_dir%/Resources/java/compiler.jar"
#yui_css:
# jar: "%kernel.root_dir%/Resources/java/yuicompressor-2.4.7.jar"
# Doctrine Configuration
doctrine:
dbal:
driver: "%database_driver%"
host: "%database_host%"
port: "%database_port%"
dbname: "%database_name%"
user: "%database_user%"
password: "%database_password%"
charset: UTF8
# if using pdo_sqlite as your database driver, add the path in parameters.yml
# e.g. database_path: "%kernel.root_dir%/data/data.db3"
# path: "%database_path%"
orm:
auto_generate_proxy_classes: "%kernel.debug%"
auto_mapping: true
# Swiftmailer Configuration
swiftmailer:
transport: "%mailer_transport%"
host: "%mailer_host%"
username: "%mailer_user%"
password: "%mailer_password%"
encryption: ssl
auth_mode: login
spool: { type: memory }
fos_user:
db_driver: orm # other valid values are 'mongodb', 'couchdb' and 'propel'
firewall_name: main
user_class: Les\UserBundle\Entity\User
registration:
confirmation:
from_email:
address: registration#lescouverts.com
sender_name: Lescouverts Registration
enabled: false
from_email:
address: noreply#lescouverts.com
sender_name: LesCouverts
services:
resto_module:
class: Les\RestoModule\Module
arguments: [module]
lists_module:
class: Les\RestoParam\Param
arguments: [parameters]
my security.yml file
security:
encoders:
FOS\UserBundle\Model\UserInterface: sha512
role_hierarchy:
ROLE_CLIENT: ROLE_USER
ROLE_RESTO: ROLE_CLIENT
ROLE_SHOP: ROLE_CLIENT
ROLE_ADMIN: [ ROLE_USER, ROLE_CLIENT, ROLE_RESTO , ROLE_SHOP ]
ROLE_SUPER_ADMIN: ROLE_ADMIN
providers:
fos_userbundle:
id: fos_user.user_provider.username
firewalls:
main:
pattern: ^/
form_login:
provider: fos_userbundle
login_path: fos_user_security_login
csrf_provider: form.csrf_provider
# check_path: /login_check
check_path: fos_user_security_check
default_target_path: /
csrf_provider: form.csrf_provider
logout:
path: fos_user_security_logout
anonymous: true
access_control:
- { path: ^/booking, role: ROLE_CLIENT }
- { path: ^/party_calendar, role: ROLE_CLIENT }
- { path: ^/restaurant_admin, role: ROLE_RESTO }
- { path: ^/shop_admin, role: ROLE_SHOP }
- { path: ^/virtual_market, role: [ ROLE_RESTO, ROLE_SHOP ] }
- { path: ^/root, role: ROLE_ADMIN }
- { path: ^/secure_area/login, role: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/secure_area/connect, role: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/secure_area, role: ROLE_USER }
I am not sure how to debug this problem!
Plus in development mode i am getting the error
RuntimeException: Failed to write cache file
"/var/www/vhosts/httpdocs/app/cache/dev/classes.php".
So i cant even see if the profiler is indicating any errors!
One common issue is that the app/cache and app/logs directories must be writable both by the web server and the command line user.
http://symfony.com/doc/current/book/installation.html#configuration-and-setup

Strange symfony2 issue when updating vendors with composer

I'm experiencing a rather strange problem with a Symfony site I'm working on. For some reason, when I write composer update or composer install I get the following result:
Loading composer repositories with package information
Updating dependencies (including require-dev)
Nothing to install or update
Generating autoload files
Updating the "app/config/parameters.yml" file
[Symfony\Component\Config\Exception\FileLoaderLoadException]
Cannot import resource "Z:\path\to\project\app/config\config.yml" from "Z:\path\to\project\app/config/config_dev.yml". (There is no ext
ension able to load the configuration for "imports" (in Z:\path\to\project\app/config\config.yml). Loo
ked for namespace "imports", found "framework", "security", "twig", "mon
olog", "swiftmailer", "assetic", "doctrine", "sensio_framework_extra", "com
mon_common", "common_security", "dashboard", "receipts", "hr",
"service", "users", "partners", "storage", "web_profiler",
"sensio_distribution")
[Symfony\Component\DependencyInjection\Exception\InvalidArgumentException]
There is no extension able to load the configuration for "imports" (in Z:\path\to\project\app/config\config.yml). Looked for namespace "imports", found "framework", "security
", "twig", "monolog", "swiftmailer", "assetic", "doctrine", "sensio_framewo
rk_extra", "common_common", "common_security", "dashboard", "receip
ts", "hr", "service", "users", "partners", "storage", "
web_profiler", "sensio_distribution"
Script Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::clearCache handling the post-update-cmd event terminated with an exception
[RuntimeException]
An error occurred when executing the ""cache:clear --no-warmup"" command.
config.yml
imports:
- { resource: parameters.yml }
- { resource: security.yml }
framework:
#esi: ~
translator: { fallback: "%locale%" }
secret: "%secret%"
router:
resource: "%kernel.root_dir%/config/routing.yml"
strict_requirements: ~
form: ~
csrf_protection: ~
validation: { enable_annotations: true }
templating:
engines: ['twig']
#assets_version: SomeVersionScheme
default_locale: "%locale%"
trusted_hosts: ~
trusted_proxies: ~
session:
# handler_id set to null will use default session handler from php.ini
handler_id: ~
fragments: ~
http_method_override: true
# Twig Configuration
twig:
debug: "%kernel.debug%"
strict_variables: "%kernel.debug%"
globals:
sitename: "%sitename%"
session: {}
# Assetic Configuration
assetic:
debug: "%kernel.debug%"
use_controller: false
bundles: [ CommonSecurityBundle ]
#java: /usr/bin/java
assets:
base_css:
inputs:
- '%kernel.root_dir%/Resources/public/css/admin.css'
- '%kernel.root_dir%/Resources/public/css/superfish/superfish.css'
timer_js:
inputs:
- '%kernel.root_dir%/Resources/public/js/time.js'
filters:
cssrewrite: ~
#closure:
# jar: "%kernel.root_dir%/Resources/java/compiler.jar"
#yui_css:
# jar: "%kernel.root_dir%/Resources/java/yuicompressor-2.4.7.jar"
# Doctrine Configuration
doctrine:
dbal:
driver: "%database_driver%"
host: "%database_host%"
port: "%database_port%"
dbname: "%database_name%"
user: "%database_user%"
password: "%database_password%"
charset: UTF8
# if using pdo_sqlite as your database driver, add the path in parameters.yml
# e.g. database_path: "%kernel.root_dir%/data/data.db3"
# path: "%database_path%"
orm:
auto_generate_proxy_classes: "%kernel.debug%"
auto_mapping: true
# Swiftmailer Configuration
swiftmailer:
transport: "%mailer_transport%"
host: "%mailer_host%"
username: "%mailer_user%"
password: "%mailer_password%"
spool: { type: memory }
config_dev.yml
imports:
- { resource: config.yml }
framework:
router:
resource: "%kernel.root_dir%/config/routing_dev.yml"
strict_requirements: true
profiler: { only_exceptions: false }
web_profiler:
toolbar: true
intercept_redirects: false
monolog:
handlers:
main:
type: stream
path: "%kernel.logs_dir%/%kernel.environment%.log"
level: debug
console:
type: console
bubble: false
# uncomment to get logging in your browser
# you may have to allow bigger header sizes in your Web server configuration
#firephp:
# type: firephp
# level: info
#chromephp:
# type: chromephp
# level: info
assetic:
use_controller: true
#swiftmailer:
# delivery_address: me#example.com
parameters.yml
# This file is auto-generated during the composer install
parameters:
database_driver: pdo_pgsql
database_host: 127.0.0.1
database_port: 5432
database_name: db_name
database_user: db_user
database_password: db_pass
mailer_transport: smtp
mailer_host: 127.0.0.1
mailer_user: null
mailer_password: null
locale: en
secret: asdBHwmI1hsjKjanJK2WD#wdnak
security.yml
security:
encoders:
Symfony\Component\Security\Core\User\User: plaintext
role_hierarchy:
ROLE_STORAGE_WRITE: ROLE_STORAGE_READ
ROLE_ADMIN: ROLE_USER
ROLE_SUPER_ADMIN: [ROLE_USER, ROLE_ADMIN, ROLE_ALLOWED_TO_SWITCH]
providers:
main_provider:
chain:
providers: [ in_memory ]
in_memory:
memory:
users:
user: { password: userpass, roles: [ 'ROLE_USER' ] }
admin: { password: password, roles: [ 'ROLE_SUPER_ADMIN' ] }
firewalls:
dev:
pattern: ^/(_(profiler|wdt)|css|images|js)/
security: false
login:
pattern: ^/login$
security: false
secured_area:
pattern: ^/
logout: true
anonymous: false
logout:
path: logout
target: /
invalidate_session: false
simple_form:
authenticator: authentication_token
check_path: login_check
login_path: login
access_control:
- { path: ^/login, roles: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/, roles: ROLE_USER }
I've got no idea why it says it can't import the files in the imports section - they exist and are writable/readable. Can someone shed a light on what's happening here?
Symfony version: 2.4.2
Composer version: 70a20ebcc19f1ea8ab0954a4fbdce208b30085e7 2014-03-12 16:07:58
Some times crazy things happen to files where extra bytes get inserted at the start of the file. You can try recreating the file with the contents by hand. Copy pasting my include those bytes.

Compile Error: Declaration of FOS\RestBundle\Request\RequestBodyParamConverter::apply() must be compatible with that of Sensio\Bundle

I'm using symfony2. I'm trying to use the Request Body convert listener from FriendsOfSymfony bundle. I have enabled the request converters on sensio_framework_extra and when enabling the body converter:
fos_rest:
body_converter:
enabled: true
I get this exception:
FatalErrorException: Compile Error: Declaration of FOS\RestBundle\Request\RequestBodyParamConverter::apply() must be compatible with that of Sensio\Bundle\FrameworkExtraBundle\Request\ParamConverter\ParamConverterInterface::apply() in /var/www/xxx/vendor/friendsofsymfony/rest-bundle/FOS/RestBundle/Request/RequestBodyParamConverter.php line 32
in /var/www/xxx/vendor/friendsofsymfony/rest-bundle/FOS/RestBundle/Request/RequestBodyParamConverter.php line 32
at ErrorHandler->handleFatalError(object(ExceptionHandler), array('type' => '64', 'message' => 'Declaration of FOS\RestBundle\Request\RequestBodyParamConverter::apply() must be compatible with that of Sensio\Bundle\FrameworkExtraBundle\Request\ParamConverter\ParamConverterInterface::apply()', 'file' => '/var/www/xxx/vendor/friendsofsymfony/rest-bundle/FOS/RestBundle/Request/RequestBodyParamConverter.php', 'line' => '32')) in /var/www/xxx/vendor/symfony/symfony/src/Symfony/Component/Debug/ErrorHandler.php line 212
Here is my full config.yml file
imports:
- { resource: parameters.yml }
- { resource: security.yml }
framework:
#esi: ~
#translator: { fallback: "%locale%" }
secret: "%secret%"
router:
resource: "%kernel.root_dir%/config/routing.yml"
strict_requirements: ~
form: ~
csrf_protection: ~
validation: { enable_annotations: true }
templating:
engines: ['twig']
#assets_version: SomeVersionScheme
default_locale: "%locale%"
trusted_hosts: ~
trusted_proxies: ~
session:
# handler_id set to null will use default session handler from php.ini
handler_id: ~
fragments: ~
http_method_override: true
# Twig Configuration
twig:
debug: "%kernel.debug%"
strict_variables: "%kernel.debug%"
# Assetic Configuration
assetic:
debug: "%kernel.debug%"
use_controller: false
bundles: [ ]
#java: /usr/bin/java
filters:
cssrewrite: ~
#closure:
# jar: "%kernel.root_dir%/Resources/java/compiler.jar"
#yui_css:
# jar: "%kernel.root_dir%/Resources/java/yuicompressor-2.4.7.jar"
# Doctrine Configuration
doctrine:
dbal:
driver: "%database_driver%"
host: "%database_host%"
port: "%database_port%"
dbname: "%database_name%"
user: "%database_user%"
password: "%database_password%"
charset: UTF8
# if using pdo_sqlite as your database driver, add the path in parameters.yml
# e.g. database_path: "%kernel.root_dir%/data/data.db3"
# path: "%database_path%"
orm:
auto_generate_proxy_classes: "%kernel.debug%"
auto_mapping: true
# Swiftmailer Configuration
swiftmailer:
transport: "%mailer_transport%"
host: "%mailer_host%"
username: "%mailer_user%"
password: "%mailer_password%"
spool: { type: memory }
# Friends of Symfony configuration
fos_rest:
body_converter:
enabled: true
routing_loader:
default_format: json
param_fetcher_listener: true
body_listener: true
format_listener: true
view:
view_response_listener: 'force'
# Sensio Framework Extra Configuration
sensio_framework_extra:
request: { converters: true }
view: { annotations: false }
router: { annotations: false }
and this is my require libraries on composer.json
"require": {
"php": ">=5.3.3",
"symfony/symfony": "~2.4",
"doctrine/orm": "~2.2,>=2.2.3",
"doctrine/doctrine-bundle": "~1.2",
"twig/extensions": "~1.0",
"symfony/assetic-bundle": "~2.3",
"symfony/swiftmailer-bundle": "~2.3",
"symfony/monolog-bundle": "~2.4",
"sensio/distribution-bundle": "~2.3",
"sensio/framework-extra-bundle": "~3.0",
"sensio/generator-bundle": "~2.3",
"incenteev/composer-parameter-handler": "~2.0",
"friendsofsymfony/rest-bundle": "1.1.0",
"jms/serializer-bundle": "dev-master"
},
anybody has any ideas?
thanks

Categories