Symfony2

Symfony2 what to do when deploying manually?

匿名 (未验证) 提交于 2019-12-03 07:50:05
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Since i can't find any useful information on Symfony2 website i'm asking here. What should be done when manually deploying a Symfony2 project ? As far i understand: Edit app/config/paramenters.ini to meet server paramenters Update vendors to the latest version: php bin/vendors update Install database with php app/console doctrine:database:create then tables with php app/console doctrine:schema:update --force and eventually load fixtures: php app/console doctrine:fixtures:load Dump and install assets/assetics: php app/console assets:install -

Symfony2: updating just one vendor bundle

匿名 (未验证) 提交于 2019-12-03 07:36:14
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Is there a way to update just one bundle without updating every bundle in your deps file? I am currently using "php vendors install" to install all vendor bundles and am not aware of any commands that will update just one bundle at a time. 回答1: 1) Just open your deps file (./deps) 2) Remove all bundles except the one you want to update and save the deps file 3) Let's run the command: php bin/vendors update It will update the bundle. 4) Go back in your deps file and rewrite all the previous removed bundle lines ! Cheers ! 回答2: Short version:

Symfony2 form validation with html5 and CANCEL button

匿名 (未验证) 提交于 2019-12-03 03:08:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have a contact form on Symfony2 where I put some validators as email, minLength etc. All those fields are also set as notBlank. Due to this, HTML5 is also validating those fields (for the email and not blank), which is fine for me. I have a submit button: <input type="submit" value="Submit"/> The problem is that I have another submit button which is a Cancel button: <input name="cancel" type="submit" value="Cancel" /> With this button, in my controller I am doing a redirect: if( $request->get('cancel') == 'Cancel' ) return $this->redirect(

Symfony2: my form returns false from isValid() but empty array for getErrors() from unique constraint condition

匿名 (未验证) 提交于 2019-12-03 03:04:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: I have a Customer entity that only has a unique Email field to it. I am trying to edit a customer's email and the validation works fine. However I have this in my controller: public function updateAction ( Request $request , $id ) { $em = $this -> getDoctrine ()-> getManager (); $entity = $em -> getRepository ( 'AcmeDemoBundle:Customer' )-> find ( $id ); if (! $entity ) { throw $this -> createNotFoundException ( 'Unable to find Customer entity.' ); } $editForm = $this -> createForm ( new CustomerType (), $entity ); $editForm ->

Symfony2: Warning: spl_object_hash() expects parameter 1 to be object, integer given

匿名 (未验证) 提交于 2019-12-03 03:02:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have a many to one relationship between the entities Project and Course because each course can have many projects so many projects could be related to the same course. These are my entities: class Project{ /** * @ORM\Id * @ORM\Column(type="integer") * @ORM\GeneratedValue(strategy="AUTO") */ protected $id; //... other fields ... //----------------------- DATABASE RELATIONSHIP ----------------// //PROJECT-COURSE - M:1 relationship /** * @ORM\ManyToOne(targetEntity="Course", inversedBy="project") * @ORM\JoinColumn(name="course_id",

Symfony2 Doctrine schema update fails

匿名 (未验证) 提交于 2019-12-03 02:56:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: I created database on my local machine. After moving my project to server I imported backup from local (because I had some important data there). Now,when I'm trying to update schema on my server it gives my this output: php app / console doctrine : schema : update -- force Updating database schema ... [ Doctrine \DBAL\Exception\ForeignKeyConstraintViolationException ] An exception occurred while executing 'ALTER TABLE golf_course ADD CONSTRAINT FK_EC96E162F1503E2B FOREIGN KEY (golf_id) REFERENCES golf (id)' : SQLSTATE [ 23000 ]:

Symfony2, composer, your PHP version (5.6.18) overriden by “config.platform.php” version (5.3.9) does not satisfy requirement

匿名 (未验证) 提交于 2019-12-03 02:56:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I am trying to install doctrine to my project. I am getting the error about the wrong PHP version. What can be done to remove the real reason for this error? The way to overcome it is to use the option " --ignore-platform-reqs " as described https://getcomposer.org/doc/03-cli.md#require . PHP version: PHP 5.6.18 PHP 5.6.18 (cli) (built: Feb 3 2016 17:20:21) Copyright (c) 1997-2016 The PHP Group Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2016, by Zend Technologies The error:

Why is session data empty in Symfony2 and how to access it?

匿名 (未验证) 提交于 2019-12-03 02:50:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: A third-party PHP application stores data in the user's session (using a cookie for PHPSESSID). In this app, the $_SESSION variable contains all this data. In my Symfony2 application, the same $_SESSION only contains some Symfony data ( _sf2_attributes , _security_secured_area , _sf2_flashes , etc.) and I don't see any other data from the other app. I did a var_dump of the $_SESSION variable in a controller to check this. Using the Symfony Session object shows the same data. The 2 apps use the same domain for storing the PHPSESSID cookie.

Cron Job in symfony2

匿名 (未验证) 提交于 2019-12-03 02:45:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I create a console command in my project. I want it to be executed everyday at 7 p.m. How could i do it in symfony2? A basic php cron job way or symfony2 have something more convenient? Thanks 回答1: You can use the basic cron . On debian or ubuntu you can do this: crontab -e -u <username> Where username is the name of the user that should execute the command. In the editor add your command. Here is a good explanation how the line should look. For a Symfony2 command something like this should work: * * * * * /usr/bin/php /var/www/symfony2/app

Symfony2 Extension - Behat Mink

匿名 (未验证) 提交于 2019-12-03 02:38:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: I installed a Symfony2 extension for Behat Mink from here When I run test, an error occurs [ReflectionException] Class AppKernel does not exist. What am I doing wrong? behat.yml default : extensions : Behat \MinkExtension\Extension : base_url : http : //localhost/behat goutte : ~ selenium2 : ~ Behat \Symfony2Extension\Extension : ~ 回答1: First run these commands to install the dependencies: composer require behat / behat composer require behat / symfony2 - extension composer require behat / mink composer require behat / mink -