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

How do I read from parameters.yml in a controller in symfony2?

I have put a couple of custom variables in my app/config/parameters.yml. parameters: api_pass: apipass api_user: apiuser I need to access these from my controller, and have tried to fetch them with $this->get('api_user'); from within my…
Bohr
  • 2,086
  • 3
  • 15
  • 19
153
votes
13 answers

How to know which version of Symfony I have?

I know that I have downloaded a Symfony2 project and started with but I have updated my vendor several times and I want to know which version of symfony I have Any idea ?
zizoujab
  • 7,603
  • 8
  • 41
  • 72
149
votes
16 answers

symfony 2 twig limit the length of the text and put three dots

How can I limit the length of the text, e.g., 50, and put three dots in the display? {% if myentity.text|length > 50 %} {% block td_text %} {{ myentity.text}}{% endblock %} {%endif%}
GRafoKI
  • 1,515
  • 2
  • 9
  • 8
147
votes
22 answers

How to set default value for form field in Symfony2?

Is there an easy way to set a default value for text form field?
Ondrej Slinták
  • 31,386
  • 20
  • 94
  • 126
142
votes
2 answers

Is it fine if first response is private with AppCache (Symfony2)?

I'm trying to use http caching. In my controller I'm setting a response as follows: $response->setPublic(); $response->setMaxAge(120); $response->setSharedMaxAge(120); $response->setLastModified($lastModifiedAt); dev mode In dev environment first…
Jakub Zalas
  • 35,761
  • 9
  • 93
  • 125
140
votes
12 answers

How to sort findAll Doctrine's method?

I've been reading Doctrine's documentation, but I haven't been able to find a way to sort findAll() Results. I'm using symfony2 + doctrine, this is the statement that I'm using inside my…
ILikeTacos
  • 17,464
  • 20
  • 58
  • 88
133
votes
4 answers

What does the tilde (~) mean in my composer.json file?

I have this line in my composer.json file: "require": { ... "friendsofsymfony/user-bundle": "~2.0@dev", ... }, What does the tilde ~ in ~2.0@dev exactly mean? Is that a placeholder and shall always fetch the subversions like 1.2.0,…
Gottlieb Notschnabel
  • 9,408
  • 18
  • 74
  • 116
126
votes
5 answers

How to get the root dir of the Symfony2 application?

What is the best way to get the root app directory from inside the controller? Is it possible to get it outside of the controller? Now I get it by passing it (from parameters) to the service as an argument, like this: services: sr_processor: …
Dawid Ohia
  • 16,129
  • 24
  • 81
  • 95
125
votes
3 answers

Empty field in yaml

I want to leave a value in my .yaml field empty, because in another translation there has to be something but not in this one. Just leaving it empty prints out the path of the value (...title.3). title: 1: String 2: String2 3:
maidi
  • 3,219
  • 6
  • 27
  • 55
124
votes
5 answers

How can I use break or continue within for loop in Twig template?

I try to use a simple loop, in my real code this loop is more complex, and I need to break this iteration like: {% for post in posts %} {% if post.id == 10 %} {# break #} {% endif %}

{{ post.heading }}

{% endfor %} How…
Victor Bocharsky
  • 11,930
  • 13
  • 58
  • 91
121
votes
2 answers

Doctrine 2 can't use nullable=false in manyToOne relation?

An User has one Package associated with it. Many users can refer to the same package. User cannot exists without a Package defined. User should own the relation. Relation is bidirectional, so a Package has zero or more users in it. These…
gremo
  • 47,186
  • 75
  • 257
  • 421
119
votes
2 answers

Add more than one parameter in Twig path

How to add more than one parameter in Twig path? Say you have this route : article_show: pattern: /article/{slug} defaults: { _controller: AcmeArticleBundle:Article:show } You can do this in your twig template : {{ path('article_show', {…
Wissem
  • 1,705
  • 4
  • 16
  • 22
117
votes
9 answers

Automatic post-registration user authentication

We're building a business app from the ground up in Symfony 2, and I've run into a bit of a snag with the user registration flow: after the user creates an account, they should be automatically logged in with those credentials, instead of being…
Problematic
  • 17,567
  • 10
  • 73
  • 85
116
votes
21 answers

Symfony2 : How to get form validation errors after binding the request to the form

Here's my saveAction code (where the form passes the data to) public function saveAction() { $user = OBUser(); $form = $this->createForm(new OBUserType(), $user); if ($this->request->getMethod() == 'POST') { …
putolaruan
  • 2,084
  • 2
  • 21
  • 32
115
votes
15 answers

"Class XXX is not a valid entity or mapped super class" after moving the class in the filesystem

I had an entity class in Aib\PlatformBundle\Entity\User.php I had no problems trying to create its form class through php app/ console doctrine:generate:form AibPlatformBundle:User Now I have change the namespace to…
tirenweb
  • 30,963
  • 73
  • 183
  • 303