Questions tagged [symfony]

Symfony refers to both a PHP framework for building web applications as well as a set of components on which the framework is built. This tag refers to the currently supported major versions 3.x, 4.x, 5.x and 6.x. Alternatively, you can specify an exact version using the respective tag. This tag should not be used for questions about Symfony 1.x. Please use the Symfony1 tag instead.

Symfony is a framework for web and CLI-applications built on top of a catalogue of Symfony components. It is free software released under the MIT license. The project's homepage is symfony.com.

Symfony aims to speed up the creation and maintenance of web applications and replace repetitive coding tasks by providing a rich set of components and integrations for other libraries through bundles. It has a low-performance overhead used with a bytecode cache and is aimed at building robust applications in an enterprise context, and aims to give developers complete control over the configuration: from the directory structure to the foreign libraries. Almost everything can be customized. To match enterprise development guidelines, Symfony is bundled with additional tools to help developers test, debug and document projects. Most of the components making up the framework can be used outside of the framework in other projects and libraries.

Components

Besides being a full-stack framework, Symfony is also a set of decoupled and Components.

Some of the Components have their own tag:

Information

This tag should be used for generic Symfony questions. You can also use other tags when the question is related to a specific version: , , , , , , , , , , , , , , , , , , , and .

If your question is about Symfony 1.x, please use instead.

The latest stable version can be found on the releases page.

Symfony also maintains Long Term Support (LTS) releases, which are held for several years (while “normal” releases are only maintained for about eight to ten months). The Symfony team is committed to providing a direct upgrade path between Long Term Support releases.

Related projects

Symfony is used as a basis for many other projects, such as , or

Useful links

Note: Before using any documentation, verify that the version of the documentation matches the Symfony version of your installation.

Upgrade between each version:

Interesting questions:


Symfony is released under the MIT license. The full license text is available on the website.

73565 questions
95
votes
13 answers

How to encode Doctrine entities to JSON in Symfony 2.0 AJAX application?

I'm developing game app and using Symfony 2.0. I have many AJAX requests to the backend. And more responses is converting entity to JSON. For example: class DefaultController extends Controller { public function launchAction() { …
Dmytro Krasun
  • 1,714
  • 1
  • 13
  • 20
95
votes
10 answers

Doctrine - A new entity was found through the relationship

since 2 weeks, we are having this problem while trying to flush new elements: CRITICAL: Doctrine\ORM\ORMInvalidArgumentException: A new entity was found through the relationship 'Comment#capture' that was not configured to cascade persist…
isundil
  • 1,051
  • 1
  • 7
  • 4
95
votes
10 answers

How to access an application parameters from a service?

From my controllers, I access the application parameters (those in /app/config) with $this->container->getParameter('my_param') But I don't know how to access it from a service (I imagine my service class is not supposed to extend…
Pierre de LESPINAY
  • 44,700
  • 57
  • 210
  • 307
95
votes
10 answers

How to merge two php Doctrine 2 ArrayCollection()

Is there any convenience method that allows me to concatenate two Doctrine ArrayCollection()? something like: $collection1 = new ArrayCollection(); $collection2 = new…
Throoze
  • 3,988
  • 8
  • 45
  • 67
93
votes
18 answers

artisan migration error "Class 'Doctrine\\DBAL\\Driver\\PDOMySql\\Driver' not found",

When trying to run a migration I get the error Artisan migration error:Class 'Doctrine\\DBAL\\Driver\\PDOMySql\\Driver' not found I have read the questions here and also see the notes to add: doctrine/dbal": "~2.3 in the requires section of…
Nancymic
  • 1,059
  • 1
  • 8
  • 10
92
votes
11 answers

Is there a built-in way to get all of the changed/updated fields in a Doctrine 2 entity

Let's suppose I retrieve an entity $e and modify its state with setters: $e->setFoo('a'); $e->setBar('b'); Is there any possibility to retrieve an array of fields that have been changed? In case of my example I'd like to retrieve foo => a, bar => b…
zerkms
  • 249,484
  • 69
  • 436
  • 539
91
votes
2 answers

What is the new Symfony 3 directory structure?

I just created a new Symfony 2.5 project with a regular composer command: php composer.phar create-project symfony/framework-standard-edition path/ 2.5.0 The Terminal asks me: Would you like to use Symfony 3 directory structure? What is this…
Ousmane
  • 2,673
  • 3
  • 30
  • 37
90
votes
4 answers

Passing data to buildForm() in Symfony 2.8, 3.0 and above

My application currently passes data to my form type using the constructor, as recommended in this answer. However the Symfony 2.8 upgrade guide advises that passing a type instance to the createForm function is deprecated: Passing type instances…
Jonathan
  • 13,947
  • 17
  • 94
  • 123
87
votes
1 answer

How do you check if an object exists in the Twig templating engine in Symfony2?

I have a multidimensional array where some objects exist and others don't. I keep getting a Method "code" for object "stdClass" does not exist in...? The code I am using in my template is: {% for item in items %}

{% if item.product.code %}{{…

Adam Stacey
  • 2,833
  • 4
  • 26
  • 38
87
votes
2 answers

Deprecation: Doctrine\ORM\Mapping\UnderscoreNamingStrategy without making it number aware is deprecated

I'm using Symfony 4.3.8 and I can't find any information about thoses deprecations : User Deprecated: Creating Doctrine\ORM\Mapping\UnderscoreNamingStrategy without making it number aware is deprecated and will be removed in Doctrine ORM…
leobrl
  • 959
  • 1
  • 6
  • 15
86
votes
2 answers

Add error to Symfony 2 form element

I check some validation in my controller. And I want to add error to specific element of my form on failure. My form: use Symfony\Component\Form\FormError; // ... $config = new Config(); $form = $this->createFormBuilder($config) …
Alex Pliutau
  • 21,392
  • 27
  • 113
  • 143
85
votes
4 answers

Accessing Files Relative to Bundle in Symfony2

In a Symfony2 app's routing configuration, I can refer to a file like this: somepage: prefix: someprefix resource: "@SomeBundle/Resources/config/config.yml" Is there any way to access a file relative to the bundle within a controller or…
Thomas Kelley
  • 10,187
  • 1
  • 36
  • 43
85
votes
4 answers

How do I fix "Add myBundle to the asseticBundle config" symfony2 exception?

When I am trying to use the TWIG {% javascript %} tag to link to my .js file it return me with the following exception : An exception has been thrown during the compilation of a template ("You must add CompetitiongameBundle to the assetic.bundle…
Manish Basdeo
  • 6,139
  • 22
  • 68
  • 102
84
votes
13 answers

How to get form values in Symfony2 controller

I am using a login form on Symfony2 with the following controller code public function loginAction(Request $request) { $user = new SiteUser(); $form = $this->createForm(new LoginType(), $user); if ($request->getMethod() == 'POST') { …
VishwaKumar
  • 3,433
  • 8
  • 44
  • 72
84
votes
4 answers

How to select distinct query using symfony2 doctrine query builder?

I have this symfony code where it retrieves all the categories related to a blog section on my project: $category = $catrep->createQueryBuilder('cc') ->Where('cc.contenttype = :type') ->setParameter('type', 'blogarticle') …
mickburkejnr
  • 3,652
  • 12
  • 76
  • 109