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
11
votes
4 answers

How to add placeholder on input in Symfony 4 form?

In my Symfony 4 form, I am try to get a placeholder for my input. I tried the below but I get an error that it is not allowed. Any ideas how else I can achieve this? ->add('firstname', TextType::class, ['label' => 'Vorname ', 'placeholder'…
felixo
  • 1,453
  • 6
  • 33
  • 60
11
votes
2 answers

Symfony 4. ServiceEntityRepository vs EntityRepository

Why do I need to extend ServiceEntityRepository in my repository? In Symfony 3.4, I always extended EntityRepository. With ServiceEntityRepository I have a strange problem described here Symfony 4. InheritanceType("JOINED") and ParamConverter.…
olek07
  • 513
  • 2
  • 7
  • 21
11
votes
2 answers

Symfony 4, Postgres - `Invalid value for parameter "client_encoding": "utf8mb4"` on running doctrine command

The Problem I have a fresh setup of postgres 10.5 and symfony 4 application running on php 7.1. But when I try running migration. I keep getting the following Invalid value for parameter "client_encoding": "utf8mb4" error. Steps to reproduce On…
Bikal Basnet
  • 1,639
  • 1
  • 21
  • 31
11
votes
4 answers

How to fetch (join) two records from database using doctrine/symfony4

I am learning about Symfony and Doctrine and created a simple site but I am stuck at this step. I have two tables: users and languages Users Contains: id, username ... Languages Contains: user_id, language... Here is a image of the two Now I am…
hidar
  • 5,449
  • 15
  • 46
  • 70
11
votes
1 answer

Setting no key prefix in symfony4 for redis

I have a problem with proper configuration for redis in Symfony 4. I want to have no prefix before my cache item keys, but it is constantly showing. Here is my config/packages/framework.yaml (part related to cache): cache: prefix_seed: ztw/ztw …
Pawel
  • 145
  • 3
  • 8
11
votes
1 answer

Symfony 4 - Set DateTime

so I've been following this Database and the Doctrine tutorial: https://symfony.com/doc/current/doctrine.html the only difference is that I added a created_ts field to it (among some other fields, but they work fine so no need to go into them). I…
treyBake
  • 6,440
  • 6
  • 26
  • 57
11
votes
2 answers

Api-Platform: Using Yaml config instead of annotations in SF 4

I'd like to use YAML instead of annotations in Api-Platform. Instead of using the Api-Platform distribution, I have added the api-pack into my existing Symfony Flex project (composer req api). The documentation says the YAML file should take place…
Ben
  • 845
  • 1
  • 8
  • 18
11
votes
2 answers

Is it possible to exclude multiple directories when using Symfony autowire?

When using autowire in Symfony 4 I used this working code: App\: resource: '../src/*' exclude: '../src/{Domain,Entity,Migrations,Tests}' That code excludes from the autowiring all this folders: - src/Domain - src/Entity - src/Migrations -…
Diguin
  • 835
  • 8
  • 17
11
votes
2 answers

Deploying to a production environment with Symfony Flex and --no-dev

I have a couple of large Symfony projects, and have noticed that after updating everything to Symfony 4 (Flex), when our deployment automation runs its normal process of: composer install --no-dev We end up with (for example) this: Symfony…
futureal
  • 3,025
  • 1
  • 22
  • 33
10
votes
1 answer

You cannot create the client used in functional tests if the "framework.test" config is not set to true

i am trying to apply functional test using WebTestCase. class CalculatorControllerTest extends WebTestCase { public function testSumPost() { $client = static::createClient(); $client->request('GET', '/calculator/sum'); …
yosef Mardini
  • 260
  • 4
  • 9
10
votes
1 answer

How to exclude exceptions from Sentry in Symfony?

I have an installation of Symfony 4.3 and I upgrade it to 4.4.19. On my old installation Sentry was working well with excluded_exception. I use it like this on sentry.yaml : sentry: dsn: "https://key@sentry.io/id" options: …
Develogg
  • 134
  • 3
  • 13
10
votes
2 answers

Symfony 4 get current user in form type?

I want to know how I can recover the current user in my FormType (EntityType)? Currently, I can only retrieve the list of registered users but not the current (connected) user. My current FormType
nemoxi
  • 530
  • 1
  • 7
  • 23
10
votes
0 answers

Api-platform filter annotation for Many To Many

I've follow the implementation of filters with annotation to load only the sources concern for one user. Very usefull, work properly. https://api-platform.com/docs/core/filters/#using-doctrine-filters BUT : I want to do the same in my entity with an…
mBbkr
  • 212
  • 3
  • 13
10
votes
3 answers

How to set initial data (not test data) in Symfony with doctrine ORM

I am new to learning Symfony, (Symfony 4.1.6) and can't figure this out. I have a database, and it contains a lot of tables for populating html select type inputs. they are in the database to ensure Foreign Key constraints in other records. Is…
Chad
  • 1,139
  • 17
  • 41
10
votes
4 answers

How to remove index.php from Symfony4 router?

I have been following Symfony 4 documentation as to how to configure a web server. https://symfony.com/doc/current/setup/web_server_configuration.html My .conf file in my apache 2.4 configuration is exactly as described in their documentation. I’m…
Miles M.
  • 4,089
  • 12
  • 62
  • 108