Questions tagged [symfony3.x]

the Symfony 3.x specific tag. Use it in addition to the symfony3 tag if your question is specific to any version of Symfony 3.

174 questions
43
votes
5 answers

How to configure PhpStorm to use symfony/phpunit-bridge

I had problems with configuring PhpStorm IDE to use http://symfony.com/doc/current/components/phpunit_bridge.html while working with Symfony 3.3. I decided to just download phpunit.phar to bin and use it instead. Symfony 3.4 (and Symfony 4), does…
my-nick
  • 691
  • 1
  • 5
  • 11
35
votes
5 answers

Choice field default value

I have the following form: public function buildForm(FormBuilderInterface $builder, array $options) { $builder ->add('type', ChoiceType::class, array( 'expanded' => true, 'multiple' => false, 'choices' => array( …
Alex Lomia
  • 6,705
  • 12
  • 53
  • 87
11
votes
3 answers

How can I set timezone in symfony 3?

I have a symfony 3 application deployed in Ubuntu 14.04 server. When I execute "date" in the command window, the server response me "Fri May 11 10:02:30 CEST 2018" but when I dump a datetime in twig as "{{ dump("now"|date) }}", the response is "May…
Argoitz
  • 339
  • 1
  • 3
  • 15
8
votes
4 answers

Autowiring in abstract classes with DI in Symfony 3.3, is it possible?

I am moving a Symfony 3.2 project to Symfony 3.3 and I would like to use DI new features. I have read the docs but so far I can make this to work. See the following class definition: use Http\Adapter\Guzzle6\Client; use…
ReynierPM
  • 17,594
  • 53
  • 193
  • 363
4
votes
2 answers

How do I properly store a datetime in Symfony 3?

I'm trying to store a mysql datetime in a Symfony repo and am getting an error. Tried several suggestions from the web and here on stack but nothing makes this error go away. This is what I'm trying to do (code is abbreviated for clarity) My entity…
pogeybait
  • 3,065
  • 2
  • 21
  • 23
3
votes
0 answers

Using encore_entry_script_tags in both parent and grand child twig template logs to console 2 times

I have parent main_layout.html.twig and inside it something like this: {% block javascripts %} {{ encore_entry_script_tags('main_layout') }} {% endblock %} {% block content %}{% endblock %} We have child user_profile_main_page.html.twig and…
Uros
  • 2,099
  • 7
  • 23
  • 50
3
votes
0 answers

Unused binding error when trying to bind logger to autowired controller constructor in Symfony 3.4

After upgrading to Symfony 3.4 from 2.8, I am attempting to get rid of warnings about using services from the container. One hang up is my controller all extend from an abstract controller which needs access to the monolog logger. I've decided to…
3
votes
1 answer

Swift_Mailer Symfony 3 add event listener to send event

How to add eventListener to swiftmailer send event? Every time i send email i create a file and attach it to email, and after sending i want to unlink that file. How to do that? Thanks. file_put_contents($path, implode(";\r\n", $result)); $message…
Andrew Vakhniuk
  • 594
  • 4
  • 12
3
votes
3 answers

How to create a page with two forms in Symfony?

I would like to have a page containing two forms Those two forms update the same entity: Account. What I did: Created two forms (AccountGeneralDataType.php & AccountPasswordType.php) Added them to the AccountController.php under the editAction…
darckcrystale
  • 1,582
  • 2
  • 18
  • 40
3
votes
1 answer

Symfony 3.4 Custom Authentication Listener

I have implemented a login form manually in Twig and I am using the default authentication provided by Symfony 3.4 (based on username and password). Users are stored in a database, therefore I have an Entity which extends AdvancedUserInterface. I am…
user1923631
  • 383
  • 2
  • 5
  • 15
3
votes
1 answer

Change field depending of other in SonataAdminBundle

In a Symfony3 project, i have a SonataAdminBundle form like this : protected function configureFormFields(FormMapper $formMapper) { $formMapper->add('rentalTime', 'choice', array( 'label' => 'Durée de location', …
LedZelkin
  • 586
  • 1
  • 10
  • 24
3
votes
0 answers

Symfony trustedproxies doesn't work

Symfony does not trust my nginx reverse proxy : I can't see the real IP of the user in my logs, everything is logged with IP 127.0.0.1 My config in app.php : Request::setTrustedProxies( ['127.0.0.1', $request->getClientIp(),…
Nanocom
  • 3,696
  • 4
  • 31
  • 46
3
votes
2 answers

Symfony 3 - Database static data in production. Fixture ? Migration ? Something else?

As much as I know, a fixture is "something used to consistently test some item, device, or piece of software". It should be used only in dev and test environnement. My context : I have a web app which proposes to sell 5 specific products. There is…
Dam Fa
  • 448
  • 4
  • 16
3
votes
3 answers

FOSUserBundle - PHPUnit - Mock a user

I am using Symfony with the FOSUserBundle and now I like to test some things like: Doctrine lifecycle Controller behind firewall For those tests I need to be a specific user or at least in a user group. How do I mock a user session so that…
LeMike
  • 3,195
  • 5
  • 25
  • 35
2
votes
1 answer

Set PHP version for Symfony project in PhpStorm

In a Symfony 3.4 project which I develop using PhpStorm I use the PhpStorm Terminal Window for running the Symfony server like php bin/console server:run This works fine. However the terminal uses the PHP version that is set in the windows…
user3440145
  • 793
  • 10
  • 34
1
2 3
11 12