symfony-2.0

Symfony2: How to deploy in subdirectory (Apache)

笑着哭i 提交于 2020-01-09 10:11:54
问题 What is the best way to deploy symfony2 application in a subdirectory or an alias ? Lets say that my application will run under: http://domain/symfonytest symfonytest is an alias to some directory in my filesystem. Is there some CLI operation that I can use ? When I try to configure it manually I see a problem with routing. Requets to http://domain/symfonytest/demo are seen by router as /symfonytest/demo Is there a way to tell router to ignore /symfonytest prefix for the whole application ?

Add Parameter to symfony2 Request deep array

不羁的心 提交于 2020-01-04 09:03:19
问题 I want to add a parameter to the ParameterBag in a symfony2 Request. So the array looks like this: array (size=2) 'editor' => array (size=6) '_token' => string '5797a4faf1fced89404b80fb04b3cadffc99695e' (length=40) 'login' => string 'editor' (length=6) 'firstName' => string 'Joh' (length=3) 'lastName' => string 'Ha' (length=2) 'address' => array (size=6) 'time_zone_code' => string 'Africa/Abidjan' (length=14) And I want to add a field to the editor array . I tried this $request->request->add

Add Parameter to symfony2 Request deep array

拜拜、爱过 提交于 2020-01-04 09:03:06
问题 I want to add a parameter to the ParameterBag in a symfony2 Request. So the array looks like this: array (size=2) 'editor' => array (size=6) '_token' => string '5797a4faf1fced89404b80fb04b3cadffc99695e' (length=40) 'login' => string 'editor' (length=6) 'firstName' => string 'Joh' (length=3) 'lastName' => string 'Ha' (length=2) 'address' => array (size=6) 'time_zone_code' => string 'Africa/Abidjan' (length=14) And I want to add a field to the editor array . I tried this $request->request->add

How to disable profiler in Symfony2 in production?

…衆ロ難τιáo~ 提交于 2019-12-22 01:44:55
问题 How to disable profiler in Symfony2 in production? I do not mean the toolbar - I mean the profiler. I want to disable it in production, I use it extensively for development so the solution with removing its bundle is a no-go. I have tried setting framework.profiler.only_exceptions to true. I have tried removing the framework.profiler section altogether. No matter what the profiler.db is growing after every request and every response contains x-debug-token header. I have double-checked the

Programmatically logout current user

和自甴很熟 提交于 2019-12-11 03:38:32
问题 I am trying to programmatically logout the current user from inside a listener. I read here that $this->get('security.context')->setToken(null); $this->get('request')->getSession()->invalidate(); does the trick but then I can't call $this->container->get('security.context')->getToken()->getUser(); anymore as the token is now NULL . How can I log out the user but still let the application run normally? I have calls to getUser() in my controller functions so I should set back the token to

DoctrineMongoDBBundle getting a fatal error in Symfony2

女生的网名这么多〃 提交于 2019-12-04 09:19:23
问题 I'm following the directions here: http://symfony.com/doc/2.0/bundles/DoctrineMongoDBBundle/index.html I have installed deps: #deps [doctrine-mongodb] git=http://github.com/doctrine/mongodb.git [doctrine-mongodb-odm] git=http://github.com/doctrine/mongodb-odm.git [DoctrineMongoDBBundle] git=http://github.com/symfony/DoctrineMongoDBBundle.git target=/bundles/Symfony/Bundle/DoctrineMongoDBBundle then did $ php bin/vendors install I added the following: # app/autoload.php $loader-

Symfony2 add reCaptcha field to registration form

帅比萌擦擦* 提交于 2019-12-04 06:37:10
I'm trying to add EWZRecaptcha to my registration form. My registration form builder looks something like this: public function buildForm(FormBuilder $builder, array $options) { $builder->add('username', 'text') ->add('password') ->add('recaptcha', 'ewz_recaptcha', array('property_path' => false)); } public function getDefaultOptions(array $options) { return array( 'data_class' => 'Acme\MyBundle\Entity\User', ); } Now, how can I add the Recaptcha Constraint to the captcha field? I tried to add this to validation.yml: namespaces: RecaptchaBundle: EWZ\Bundle\RecaptchaBundle\Validator\Constraints

Disable CSRF token on login form

本秂侑毒 提交于 2019-11-30 06:41:59
I am using Symfony2.0 and FOSUserBundle, and would like to disable the csrf token on my login form. I have disabled the csrf protection globally on my website in my config.yml: framework: csrf_protection: enabled: false This is working well, there is no csrf field added to my forms. However, this does not apply to the login form. On this form only, I get an "Invalid CSRF Token" error if I don't include the token in the form with: <input type="hidden" name="_csrf_token" value="{{ csrf_token }}" /> How can I disable the CSRF token on the login form? If you just go to your security.yml file and

Doctrine2 LEFT JOIN with 2 conditions

安稳与你 提交于 2019-11-29 13:24:34
I'm trying to find a 'Product' by ID, and to left join all it's 'Photo' on two conditions: the locale AND the active state. Here's my QueryBuilder : $queryBuilder = $this->createQueryBuilder('p') ->select('p, photos, photoTranslation') ->leftJoin('p.photos', 'photos') ->leftJoin('photos.translations', 'photoTranslation') ->where('p.id = :id') ->andWhere('(photoTranslation.locale = :locale OR photoTranslation.locale IS NULL)') ->andWhere('(photoTranslation.active = :active OR photoTranslation.active IS NULL)') ->setParameters(array( 'id' => $id 'locale' => $this->getLocale(), 'active' => true )

Disable CSRF token on login form

谁都会走 提交于 2019-11-29 06:21:07
问题 I am using Symfony2.0 and FOSUserBundle, and would like to disable the csrf token on my login form. I have disabled the csrf protection globally on my website in my config.yml: framework: csrf_protection: enabled: false This is working well, there is no csrf field added to my forms. However, this does not apply to the login form. On this form only, I get an "Invalid CSRF Token" error if I don't include the token in the form with: <input type="hidden" name="_csrf_token" value="{{ csrf_token }}