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
115
votes
20 answers

Warning: "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"?

I have php7.3 and symfony2.8 When I try to create the classes with the console I get this error: [Symfony\Component\Debug\Exception\ContextErrorException]Warning: "continue" targeting switch is equivalent to "break". Did you mean to use…
tenderfoot
  • 1,167
  • 2
  • 6
  • 4
114
votes
6 answers

Problems with lib-icu dependency when installing Symfony 2.3.x via Composer

I've had no problems installing Symfony 2.2.x using Composer, I've always just copied the stable version at http://symfony.com/download. composer create-project symfony/framework-standard-edition myproject/ 2.2.1 (I have Composer installed…
Mark Fox
  • 8,694
  • 9
  • 53
  • 75
111
votes
12 answers

Why composer install timeouts after 300 seconds?

I have small project made in symfony2 when I try to build it on my server it's always fails when unzipping symfony. Build was OK and suddenly composer won't unzip symfony and I didn't change anything. I tried to build with Jenkins and also manually…
zajca
  • 2,288
  • 4
  • 30
  • 40
109
votes
4 answers

Symfony2 and Doctrine - Error: Invalid PathExpression. Must be a StateFieldPathExpression

I have an entity that looks like this: /** * @Gedmo\Tree(type="nested") * @ORM\Table(name="categories") * @ORM\Entity() */ class Category extends BaseCategory { /** * @ORM\OneToMany(targetEntity="Category", mappedBy="parent") */ …
Mike
  • 12,359
  • 17
  • 65
  • 86
108
votes
2 answers

Symfony 2: How do I check if a user is not logged in inside a template?

In Symfony 2 templates (using Twig), how can I effectively check whether a user is not logged in? I don't want to use ROLE checks. I want a straightforward way to check if a user is not logged in. I'm aware that comparing app.user.username with anon…
Tool
  • 12,126
  • 15
  • 70
  • 120
107
votes
21 answers

The EntityManager is closed

[Doctrine\ORM\ORMException] The EntityManager is closed. After I get a DBAL exception when inserting data, EntityManager closes and I'm not able to reconnect it. I tried like this but it didn't get a…
Ueli
  • 2,301
  • 5
  • 25
  • 29
106
votes
1 answer

cascade={"remove"} VS orphanRemoval=true VS ondelete="CASCADE

I tried to gather some information about the following way to delete automatically child entity when a parent entity is deleted. Seems that the most common way is to use one those three annotation: cascade={"remove"} OR orphanRemoval=true OR…
Alexis_D
  • 1,908
  • 3
  • 16
  • 35
105
votes
14 answers

Getting the base url of the website and globally passing it to twig in Symfony 2

I'm making the switch from CodeIgniter to Symfony 2. Can someone please give me an example of how to: Get the base url (the url without the route specific parts) Globally pass this variable to the twig bundle so I can use it in every template.
Geoffrey De Vylder
  • 3,963
  • 7
  • 36
  • 56
104
votes
6 answers

Path of assets in CSS files in Symfony 2

Problem I have a CSS file with some paths in it (for images, fonts, etc.. url(..)). My path structure is like this: ... +-src/ | +-MyCompany/ | +-MyBundle/ | +-Resources/ | +-assets/ | +-css/ | +-stylesheets... +-web/ |…
apfelbox
  • 2,625
  • 2
  • 24
  • 26
104
votes
1 answer

Symfony get Asset Name in Assetic output

I generate my file with code like this: {% block head_stylesheets %} {% stylesheets filter='?uglifycss' '@MyBundle/Resources/public/less/myfile.less' %}
BENARD Patrick
  • 30,363
  • 16
  • 99
  • 105
103
votes
3 answers

Get the environment name in a Twig template with Symfony2

Is there a way to get the name of the current environment in a Twig template? I'd like to set some CSS style values depending on it.
GergelyPolonkai
  • 6,230
  • 6
  • 35
  • 69
101
votes
3 answers

Accessing the logged-in user in a template

I'm using FOSuserbundle to get started with User registration https://github.com/FriendsOfSymfony/FOSUserBundle I've got it registering / logging in and out. What I want to do now is grab the logged in users data and present it on every page of my…
ed209
  • 11,075
  • 19
  • 66
  • 82
98
votes
4 answers

Symfony 2 EntityManager injection in service

I've created my own service and I need to inject doctrine EntityManager, but I don't see that __construct() is called on my service, and injection doesn't work. Here is the code and configs:
Andrey Zavarin
  • 1,483
  • 2
  • 13
  • 12
96
votes
9 answers

Access POST values in Symfony2 request object

OK, this is a newbie question, but I can't find the answer anywhere. In a controller in Symfony2, I want to access the POST value from one of my forms. In the controller I have: public function indexAction() { $request =…
Acyra
  • 15,864
  • 15
  • 46
  • 53
96
votes
6 answers

How can I send JSON response in symfony2 controller

I am using jQuery to edit my form which is built in Symfony. I am showing the form in jQuery dialog and then submitting it. Data is entering correctly in database. But I don't know whether I need to send some JSON back to jQuery. Actually I am bit…
Mirage
  • 30,868
  • 62
  • 166
  • 261