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 and 5.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 catalog 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 to 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 full 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

Beside being a full-stack framework, Symfony is also a set of decoupled and standalone components.

Symfony components

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 roadmap page.

Symfony also maintains Long Term Support (LTS) releases, which are maintained for several years (while “normal” releases are only maintained for about eight to ten months). The current LTS release is Symfony 3.4, being maintained until November of 2020 and will receive security updates until November 2021. The Symfony team is committed to provide a direct upgrade path between Long Term Support releases.

Useful links

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

Changelog:

Upgrade between each version:

Interesting questions:

Related tags


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

68963 questions
373
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
  • 10,875
  • 15
  • 64
  • 116
307
votes
33 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
  • 3,161
  • 2
  • 7
  • 14
244
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
  • 8,473
  • 15
  • 58
  • 111
239
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,459
  • 4
  • 19
  • 26
234
votes
37 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,401
  • 2
  • 10
  • 8
227
votes
10 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,706
  • 4
  • 15
  • 18
210
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,122
  • 3
  • 23
  • 30
209
votes
10 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,026
  • 15
  • 41
  • 51
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
  • 9,621
  • 9
  • 42
  • 75
193
votes
6 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,301
  • 17
  • 86
  • 144
185
votes
7 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,467
  • 4
  • 18
  • 23
175
votes
4 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,374
  • 4
  • 18
  • 29
175
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,279
  • 2
  • 24
  • 41
162
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
  • 11,333
  • 14
  • 59
  • 80
150
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
  • 1,966
  • 2
  • 14
  • 19
1
2 3
99 100