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
84
votes
1 answer

Doctrine: cascade="remove" vs orphanRemoval=true

What is the difference between the 2 options above? When is it preferable to choose each option?
iiirxs
  • 4,493
  • 2
  • 20
  • 35
82
votes
5 answers

What do scale and precision mean when specifying a decimal field type in Doctrine 2?

I'm creating a decimal field to hold a financial figure in Doctrine2 for my Symfony2 application. Currently, it looks like this: /** * @ORM\Column(type="decimal") */ protected $rate; When I entered a value and said value was persisted to the…
Anonymous
  • 6,181
  • 7
  • 45
  • 72
82
votes
7 answers

Doctrine Listener versus Subscriber

I'm working in the Symfony2 framework and wondering when would one use a Doctrine subscriber versus a listener. Doctrine's documentation for listeners is very clear, however subscribers are rather glossed over. Symfony's cookbook entry is similar.
nurikabe
  • 3,802
  • 2
  • 31
  • 39
81
votes
1 answer

Difference between assetic:dump and assets:install

In Symfony2, what is the difference between assetic:dump and assets:install? In what scenarios should each of these commands be used, and in what order (if order is relevant)?
Richard Keller
  • 1,980
  • 2
  • 19
  • 32
81
votes
6 answers

How to inject a repository into a service in Symfony?

I need to inject two objects into ImageService. One of them is an instance of Repository/ImageRepository, which I get like this: $image_repository = $container->get('doctrine.odm.mongodb') ->getRepository('MycompanyMainBundle:Image'); So how…
ChocoDeveloper
  • 14,160
  • 26
  • 79
  • 117
80
votes
4 answers

What is a "weak route" in Symfony 2?

When using the Symfony2 plugin for PHPStorm, I sometimes see a Weak Route warning: What does it mean?
Tamlyn
  • 22,122
  • 12
  • 111
  • 127
80
votes
3 answers

Symfony2 - creating own vendor bundle - project and git strategy

We're considering creating our own common bundle for entity mapping and services for use within few separate apps. A bundle should be easy to modify, run, include and test. I know about Best Practices for Structuring Bundles, but I don't know what…
ex3v
  • 3,518
  • 4
  • 33
  • 55
79
votes
7 answers

How to check if a user is logged in Symfony2 inside a controller?

I read here how to check the login status of a user by inside a twig template for a Symfony2-based website. However, I need to know how to check if the user is logged in from inside a controller. I was quite sure the the following code was…
JeanValjean
  • 17,172
  • 23
  • 113
  • 157
78
votes
16 answers

webpack: Cannot read property 'match' of undefined

I have installed webpack (Symfony encore) using npm as follows: sudo npm install -g @symfony/webpack-encore --save-dev I ran this from /var/www/project I was required to install globally due to issues with package managers and shared folders when…
Alex.Barylski
  • 2,843
  • 4
  • 45
  • 68
78
votes
7 answers

Symfony2 and date_default_timezone_get() - It is not safe to rely on the system's timezone settings

I have a Symfony2 project. I updated my php to 5.5.7 today and since then, I am getting the Warning: date_default_timezone_get(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the…
Milos Cuculovic
  • 19,631
  • 51
  • 159
  • 265
78
votes
5 answers

Getting all request parameters in Symfony 2

In symfony 2 controllers, every time I want to get a value from post I need to run: $this->getRequest()->get('value1'); $this->getRequest()->get('value2'); Is there any way to consolidate these into one statement that would return an array?…
ContextSwitch
  • 2,830
  • 6
  • 35
  • 51
77
votes
1 answer

Symfony2 security functions in Twig? How to check the user's role?

I have Symfony 2.0.9 standard edition installed with JMSSecurityBundle. Just wondering what functions are available to me in a Twig template to deal with users? Specifically I want check to see if a user has the role ROLE_ADMIN. Any help? Thanks
Chris Tickner
  • 2,008
  • 2
  • 20
  • 24
76
votes
5 answers

How do I get the user IP address in Symfony2 controller?

I need to store the IP address of the users who comment, in the database after form submission. Is there any symfony2 function to get the IP? Or any other way to get the IP?
VishwaKumar
  • 3,433
  • 8
  • 44
  • 72
76
votes
10 answers

Slow updating of composer dependencies, despite --prefer-dist flag

Why does it take up to two minutes for my composer dependencies to update, even when there have been no changes? A popular suggestion is to append the --prefer-dist flag: php composer.phar update --prefer-dist But this makes no difference in my…
Jonathan
  • 13,947
  • 17
  • 94
  • 123
76
votes
8 answers

Symfony2 - Validation not working for embedded Form Type

I have a form that combines two entities (User and Profile). Validation seems to work on the first part of the form that comes form the User Entity and is the basis of the form. The ProfileType is included inside the UserType. The form renders…
Mr Pablo
  • 4,109
  • 8
  • 51
  • 104