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

How to update a single library with Composer?

I need to install only 1 package for my SF2 distribution (DoctrineFixtures). When I run php composer.phar update I get - Updating twig/twig (dev-master 39d94fa => v1.13.0) The package has modified files: M CHANGELOG M…
Tool
  • 12,126
  • 15
  • 70
  • 120
380
votes
24 answers

Composer require runs out of memory. PHP Fatal error: Allowed memory size of 1610612736 bytes exhausted

I am trying to add HWIOAuthBundle to my project by running the below command. composer require hwi/oauth-bundle php-http/guzzle6-adapter php-http/httplug-bundle HWIOAuthBundle github: https://github.com/hwi/HWIOAuthBundle When I try to run composer…
Brian Chen
  • 4,001
  • 3
  • 9
  • 15
296
votes
2 answers

What is the difference between .yaml and .yml extension?

I read them on YAML-wikipedia but not really understood the main difference between them. I saw there are someone using .yaml extension, however, Symfony2 use .yml extension. YAML is a human-readable data serialization format that takes concepts…
lvarayut
  • 13,963
  • 17
  • 63
  • 87
261
votes
3 answers

On delete cascade with doctrine2

I'm trying to make a simple example in order to learn how to delete a row from a parent table and automatically delete the matching rows in the child table using Doctrine2. Here are the two entities I'm using: Child.php:
rfc1484
  • 9,441
  • 16
  • 72
  • 123
257
votes
41 answers

Running Composer returns: "Could not open input file: composer.phar"

I am new to symfony2 and reading symblog. In third chapter while trying with data-fixtures I tried the command: php composer.phar update but I got the error: Could not open input file: composer.phar So I googled a little and tried php…
user3291745
  • 2,629
  • 2
  • 12
  • 8
248
votes
13 answers

How to get current route in Symfony 2?

How do I get the current route in Symfony 2? For example, routing.yml: somePage: pattern: /page/ defaults: { _controller: "AcmeBundle:Test:index" } How can I get this somePage value?
IlyaDoroshin
  • 4,659
  • 4
  • 22
  • 26
240
votes
11 answers

How to render a DateTime object in a Twig template

One of my fields in one of my entities is a "datetime" variable. How can I convert this field into a string to render in a browser? Here is a code snippet: {% for game in games %} ... {{game.gameTeamIdOne.teamName}} …
Chris Ridmann
  • 2,836
  • 4
  • 18
  • 19
237
votes
11 answers

Count Rows in Doctrine QueryBuilder

I'm using Doctrine's QueryBuilder to build a query, and I want to get the total count of results from the query. $repository = $em->getRepository('FooBundle:Foo'); $qb = $repository->createQueryBuilder('n') ->where('n.bar = :bar') …
Acyra
  • 15,864
  • 15
  • 46
  • 53
218
votes
16 answers

How to get the request parameters in Symfony 2?

I am very new to symfony. In other languages like java and others I can use request.getParameter('parmeter name') to get the value. Is there anything similar that we can do with symfony2. I have seen some examples but none is working for me. Suppose…
Abdul Hamid
  • 3,222
  • 3
  • 24
  • 31
208
votes
6 answers

Should everything really be a bundle in Symfony 2.x?

I'm aware of questions like this, where people tend to discuss the general Symfony 2 concept of bundle. The thing is, in a specific application, like, for instance, a twitter-like application, should everything really be inside a generic bundle,…
Daniel Ribeiro
  • 10,156
  • 12
  • 47
  • 79
208
votes
5 answers

How to display string that contains HTML in twig template?

How can I display a string that contains HTML tags in twig template? My PHP variable contains this html and text: $word = ' a word '; When I do this in my twig template: {{ word }} I get this: <b> a word <b> I want this…
Gildas Ross
  • 3,812
  • 5
  • 21
  • 31
207
votes
8 answers

Get current URL in Twig template?

I looked around for the code to get the current path in a Twig template (and not the full URL), i.e. I don't want http://www.sitename.com/page, I only need /page.
Mark Cibor
  • 2,737
  • 4
  • 21
  • 23
196
votes
7 answers

How do I read configuration settings from Symfony2 config.yml?

I have added a setting to my config.yml file as such: app.config: contact_email: somebody@gmail.com ... For the life of me, I can't figure out how to read it into a variable. I tried something like this in one of my controllers: $recipient…
josef.van.niekerk
  • 11,941
  • 20
  • 97
  • 157
184
votes
8 answers

How to get config parameters in Symfony2 Twig Templates

I have a Symfony2 Twig template. I want to output the value of a config parameter in this twig template (a version number). Therefore I defined the config parameter like this: parameters: app.version: 0.1.0 I'm able to use this config parameter…
Timo Haberkern
  • 4,409
  • 2
  • 27
  • 41
157
votes
7 answers

How do I get the entity that represents the current user in Symfony2?

I am using the Symfony security setup. Everything works fine, but I don't know how to do one important thing: In twig, I can reach the current user's info by doing: Welcome, {{ app.user.username }} or similar How do I access this same information…
Robert Martin
  • 16,759
  • 15
  • 61
  • 87
1
2 3
99 100