Questions tagged [symfony-2.1]

This is the Symfony 2.1.x specific tag. Use it in addition to the symfony2 tag if your question is specific to Symfony 2.1.x — not just 2.x.

Symfony is a PHP full-stack web framework developed and maintained by Sensio Labs.

As of May 2013, 2.1 is deprecated in favor of the newer versions.

Information

This tag is specific for the 2.1 version of Symfony, which has been released on the 6 September 2012. See the tag for general Symfony 2.x questions.

Symfony 2.1 code is hosted and versioned on github.

As of 2 June 2013, the latest stable release of Symfony 2.1 is version 2.1.11.

Useful links

1094 questions
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
108
votes
9 answers

Too much data with var_dump in symfony2 doctrine2

I have around 40 entities and many bidirectional relationships. Whenever i use var_dump($user) or any entity my browser gets loaded with too much data of arrays and variables then it just crashed. i want to whats the problem. The data is being…
Mirage
  • 30,868
  • 62
  • 166
  • 261
59
votes
7 answers

How to get list of all routes of a controller in Symfony2?

I have a controller which implements all routes/URL(s). I had the idea to offer a generic index over all help-pages. Is there a way to get all routes defined by a controller (from within a controller) in Symfony2?
Sammy
  • 1,178
  • 1
  • 14
  • 27
54
votes
4 answers

Deep clone Doctrine entity with related entities

I have created an entity A with OneToMany relation to B, which have relation OneToMany to C. I have to clone this A entity and set it in database with new id. Also all deep relations should be cloned with new ids too. What have I tried is to set A…
hsz
  • 148,279
  • 62
  • 259
  • 315
51
votes
4 answers

Set default value on Datetime field in symfony2 form

I have a form containing several fields. One of them is a Datetime field. How to define a default value for that field? I've tried setting a value on the related entity, in controller, in constructor and __construct : $myEntity = new…
i.am.michiel
  • 10,281
  • 7
  • 50
  • 86
51
votes
7 answers

How do I force doctrine to reload the data from the database?

I'm using doctrine/mongodb 1.0.0-BETA1 in a symfony2.1 install. So i'm trying to force my repository to call data from my database instead of using the object it has cached. $audit =…
daSn0wie
  • 879
  • 1
  • 8
  • 15
49
votes
1 answer

How to create a good hypermedia format using JMSSerializerBundle?

Lets say I want to create an XML-response that will looks something like the following: 1234 Red Stapler
PatrikAkerstrand
  • 45,315
  • 11
  • 79
  • 94
47
votes
1 answer

How can i simulate a 404 error with Symfony2?

so i'm looking for a way to simulate an 404 error, i tried this : throw $this->createNotFoundException(); and this return new Response("",404); but none does work.
Rachid O
  • 13,013
  • 15
  • 66
  • 92
42
votes
4 answers

Troubleshooting "require_once(../bootstrap.php.cache): failed to open stream: No such file or directory"

I am trying to redeploy a Symfony 2.1x project I have been working on and app_dev.php is failing because it can't find app/bootstrap.php.cache. This file is omitted from the project's git repository because I used Symfony2's recommend .gitignore…
jcroll
  • 6,875
  • 9
  • 52
  • 66
38
votes
3 answers

Symfony 2 - How to delete a bundle?

So my question is how to delete bundle I created? You create bundles with this console command: php app/console generate:bundle --namespace=Test/BlogBundle --format=yml And thats awsome but what if I need to delete this bundle? Is there a console…
Limeni
  • 4,954
  • 8
  • 31
  • 33
33
votes
4 answers

How to avoid composer discard changes message

I'm updating symfony verdors via composer. I always do it using: php composer.phar update But recent version of composer, before update each package show a message like this: - Updating doctrine/data-fixtures dev-master (a95d783 => a28b6bd) The…
smoreno
  • 3,129
  • 3
  • 32
  • 49
26
votes
1 answer

Redirect after login in Symfony 2

In Symfony 2 you can set up a target for the logout so that after logout you will be redirected to /main. However with the login you will be redirected to /. Is there a manner to setup a target for a (successful) login as well? firewalls: dev: …
Roel Veldhuizen
  • 4,613
  • 8
  • 44
  • 78
25
votes
5 answers

Sonata Admin Bundle: DatePicker range

How would I create a doctrine_orm_datetime_range filter in the Sonata Admin Bundle which uses the jQuery UI datepicker? I tried the following, but it doesn't work: protected function configureDatagridFilters(DatagridMapper $datagridMapper) { …
25
votes
2 answers

JMSSerializerBundle. no control over third party meta data

I have two entities I wish to serialize with the JMSSerializerBundle. The Music Entity has a mapping-file with exclusion_policy: NONE. The Music entity has a field of the entity User from FOSUserBundle. The User entity has a mapping-file with…
tolgap
  • 9,629
  • 10
  • 51
  • 65
24
votes
3 answers

How do I add an unbound field to a form in Symfony which is otherwise bound to an entity?

Maybe I'm missing the obvious but how do I (or can I) add an extra "unbound" field to a Symfony form that is otherwise bound to an entity? Let's say I have an entity with fields first_name and last_name. I do the typical thing in my form class…
tetranz
  • 1,932
  • 3
  • 24
  • 32
1
2 3
72 73