Questions tagged [symfony4]

Symfony is a PHP framework developed by SensioLabs. Symfony 4 was released in November 2017.

Symfony is a PHP web framework first released in July 2011 and was created by SensioLabs. Symfony 4 was released in November 2017. The latest LTS is 4.4.8 released in November 2019 and has support until 2022.

Differences from Symfony 3

  • Symfony Flex automates many of the tasks that previously had to be done manually - it’s based on Symfony Recipes, which are a set of automated instructions.
  • Version 4 also recommends a bundle-less setup, e.g. putting many of the source files directly in /src instead of something like /src/AppBundle.
  • Installing using the Symfony skeleton will create a relative small version of the app. Additional packages need to be added. A more fully-featured version (more similar to the »Symfony Standard Edition« in Symfony 3) is available with the Symfony Demo Application.
  • Minimum PHP 7.1.3

Documentation / Resources

  • Overview: Documentation for current version.
  • Flex: New way to manage Symfony apps.
  • Best Practices: Best practices for developing web apps, esp. the ones using the full-stack Symfony framework.
  • Symfony Recipes Server: Includes official and community recipes.
4007 questions
6
votes
0 answers

Exclude log entries based on channel and level from Symfony logging

My Current configuration: monolog: handlers: target_main: type: fingers_crossed action_level: debug handler: file_log channels: ['!security' '!request'] file_log: …
Mindau
  • 61
  • 1
6
votes
1 answer

Symfony Serializer XML add custom attribute to root node

When generating an XML file with Serializer component (in Symfony4) I want to add a custom attribute to the root node but I can't figure out how to. The docs mention how to name the root node, but not how to add custom attributes. In my service I…
Miguel
  • 201
  • 1
  • 7
6
votes
1 answer

How to mock the Symfony HttpClient as a dependecy?

I have a class into which I inject an instance of Symfony\Component\HttpClient\HttpClient as a constructor parameter. I'm looking at the documentation page at…
Andy
  • 2,095
  • 1
  • 29
  • 59
6
votes
1 answer

Functional Testing Events and Subscribers in Symfony 4

I need to functionally test the a subscriber in Symfony 4 and I'm having problems finding how. The Subscriber has the following structure /** * Class ItemSubscriber */ class ItemSubscriber implements EventSubscriberInterface { /** * @var…
Belen
  • 673
  • 2
  • 10
  • 25
6
votes
1 answer

Symfony 4.4 unknown inky_to_html filter

I recently updated Symfony to 4.4 (from 4.3) and can't have my translations files updated automatically (using php bin/console tran:up --force) any more. The error that pops up is: In body.html.twig line 1: Unknown "inky_to_html" filter. The file…
Select0r
  • 12,234
  • 11
  • 45
  • 68
6
votes
4 answers

Sending email using office365 server with swiftmailer in symfony

I'm trying to send an confirmation email after registration using swiftmailer and office365 server in symfony. I've tried every combination of host,port and encryption type I've come across. Currently my .env file contains this…
Mario Klisanic
  • 545
  • 2
  • 9
  • 18
6
votes
1 answer

symfony 4 - bugsnag - Ignore specific exception type

I use bugsnag to log errors for our app. The app is built over symfony 4 and I have a custom listener that catches exceptions and treats some of them. What I need is to tell bugsnag to ignore the exceptions that I manually handle (there is no need…
zozo
  • 8,230
  • 19
  • 79
  • 134
6
votes
4 answers

An exception occurred in driver: SQLSTATE[HY000] [1045] Access denied for user 'db_user'@'localhost' (using password: YES)

I followed this documentation to add doctrine to my symfony project(v4.2). But when doctrine is installed it deosn't add this line to my project ( in my .env file like mentioned in the doc…
hafida Bo
  • 143
  • 1
  • 2
  • 12
6
votes
2 answers

base64 image to image file with Symfony and VichUploader

In symfony, I have an entity Program, which has the attribute image. Uploading images, naming them and putting them in the right directory is done with the VichUploaderBundle. The entity looks like this: //... /** * NOTE: This is not a mapped…
Dirk J. Faber
  • 4,360
  • 5
  • 20
  • 58
6
votes
1 answer

Service "form.factory" not found when calling createForm

I follow a class where there's an example how to make a form. When I try it I get a ServiceNotFoundException error and I can't find it anywhere on the web. Service "form.factory" not found: the container inside "App\Controller\MyTestController"…
6
votes
1 answer

How to use the logger in a console command on Symfony 4?

I've recently gone from using Symfony 2.7 to 4.2. Previously in my commands in order to log to a file I used something like: $logger = $this->getContainer()->get('logger'); $logger->error('put this in log'); This functionality appears to have…
John Sayce
  • 63
  • 1
  • 3
6
votes
2 answers

Symfony 4 "Connection refused" while trying to connect to docker mysql container

My question is how to configure connection to mysql container. Here is my docker-compose.yml version: '3' services: php: build: ./php-fpm volumes: - ./iym:/var/www/iym - ./php-fpm/php.ini:/usr/local/etc/php/php.ini …
LeshaZ
  • 660
  • 8
  • 12
6
votes
2 answers

Tree builder without a root node deprecated since Symfony 4.2 during functional tests

I'm setting up a Symfony 4.2.2 application, and I want to run functional tests with Gitlab-CI. But I'm facing this issue: A tree builder without a root node is deprecated since Symfony 4.2 and will not be supported anymore in 5.0. The strange thing…
lobodol
  • 184
  • 2
  • 12
6
votes
2 answers

How to make a generic repository in Symfony 4

I'm working with Symfony 4, I've a lot of repositories with common behaviour, so I want to avoid repeated code. I tried to define a parent repository class this way:
Genarito
  • 3,027
  • 5
  • 27
  • 53
6
votes
0 answers

SaaS, multi-tenant architecture with Symfony 4 (one app many databases)?

I've been looking for a multi-tenant architecture solution with Symfony 4 & Doctrine for a long time, where we have single App and many databases. So, i've managed a little with this: sf4-multi-tenancy. But i'm not sure if is good solution. If…
Adilet M.
  • 119
  • 1
  • 5