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
8
votes
2 answers

Symfony form: Uploaded file - "This value should be of type string"

[UPDATED]: 2019/06/24 - 23;28 Uploading a file with a form, I encounter the following error: This value should be of type string The form builder is set to FileType as it should: FormType class DocumentType extends AbstractType { public…
Preciel
  • 2,666
  • 3
  • 20
  • 45
8
votes
3 answers

How can I make a symfony 4 command to be registered only in dev environment and disabled in prod?

In my App I have a helper class App\Command\GenerateFixturesCommand that provides a command named my-nice-project:generate-fixtures. This command consumes a service of my own project named App\Services\CatalogFixtureGenerator that generates 1000…
Xavi Montero
  • 9,239
  • 7
  • 57
  • 79
8
votes
2 answers

Validation for Rest Api in Symfony 4

I'm going to write REST API for my project. I'm using symfony 4. I saw several examples, but non of them fit me. Validation with Form object. It doesn't work for me, because it's API, there are no forms. I don't want to write dummy classes just to…
Hevyweb
  • 402
  • 1
  • 5
  • 18
8
votes
2 answers

Previously executed migration are not registered migrations

I'm trying to update my database with those commands php bin/console make:migration this return success But when I try php bin/console doctrine:migrations:migrate I have this error: WARNING! You have 5 previously executed migrations in the…
Minirock
  • 628
  • 3
  • 13
  • 28
8
votes
1 answer

How to expose a property which depends on a serialization group from API-Platform to react-admin?

I use Changing the Serialization Context Dynamically in my application to apply the admin:write group when the user is an admin. So that an user on the admin will be able to update this property. The context builder has this…
A.L
  • 10,259
  • 10
  • 67
  • 98
8
votes
4 answers

Syntax error or access violation: 1064 You have an error in your SQL In symfony

When i run comand php bin/console doctrine:migration:migrate i got this error I don't know where is come from. command line error : In AbstractMySQLDriver.php line 99: An exception occurred while executing 'CREATE TABLE user (id INT AUTO_INCREMENT…
Abdo Abo
  • 93
  • 1
  • 2
  • 13
8
votes
4 answers

Redirect response from Event Subscriber in Symfony PHP

I'm trying to return a permanent (301) redirect response from a event subscriber hooked into the kernel events in Synfony PHP. My subscriber is as follow: use Symfony\Component\EventDispatcher\EventSubscriberInterface; use…
yevg
  • 1,846
  • 9
  • 34
  • 70
8
votes
4 answers

How do you pass the parent entity to a form in Symfony?

Suppose I have two entities: a post and a comment. Each post can have many comments. Now, suppose I have a comment form. It is supposed to take user input and store it in the database. Simple stuff. At least, it should be, but I can't get it to…
Nathanael
  • 6,893
  • 5
  • 33
  • 54
8
votes
1 answer

Symfony 4 how to implement Doctrine XML ORM mapping

Symfony 4 document is unclear about how to use XML orm mapping instead of annotations. It's rather frustrating to see no details for such important part in official documentation.
Nero
  • 1,555
  • 1
  • 13
  • 28
8
votes
2 answers

How to enable profiler in symfony 4

Solved: I re-install it all over again and now it contains the web_profiler.yalm inside. Thanks to all. The original question was: I´m just starting to learn Symfony so I downloaded the free videos at KnpUniversity to get started. When I reached…
Nestor
  • 519
  • 1
  • 7
  • 21
8
votes
2 answers

Check if entity property exists

I have an URL like example.org/overview// (example: example.org/overview/color/red) which will cause a search in a column "color" for the value "red". This is the entity:
Michon
  • 95
  • 1
  • 5
8
votes
1 answer

How to implement a Modular Architecture with symfony4

I would like to follow the recommendations of this article from Sander Mak, which advocates using a traditional Monolithic Architecture making use of modules instead of Microservices which are not a good choice in many cases…
Erwan Rouzel
  • 81
  • 1
  • 2
8
votes
3 answers

Symfony manually wiring arguments - 'arguments' vs 'bind'

I try to figure out how to manually inject arguments to DefaultController (without autowiring). And there are two ways I have found to achieve this. I can use arguments: services: _defaults: autowire: false autoconfigure: true …
Alexey Chuhrov
  • 1,787
  • 12
  • 25
8
votes
5 answers

My Symfony routes are throwing a 404?

I'm trying to get back into development, trying to set up Symfony on a shared hosting server with GoDaddy. I am going through the tutorial with Symfony 4 (Here: http://symfony.com/doc/current/page_creation.html) but the URL.co.uk/lucky/number is…
Marshiewooooooo
  • 179
  • 1
  • 2
  • 12
8
votes
1 answer

Symfony 4 - The autoloader expected class […] to be defined in file

I'm trying to add an old Bundle that I have built on Symfony 3.* to Symfony 4 but I get this error: The autoloader expected class "App\SBC\TiersBundle\Controller\ChantierController" to be defined in file …
SlimenTN
  • 3,383
  • 7
  • 31
  • 78