Questions tagged [symfony-2.8]

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

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

Information

This tag is specific for the 2.8 version of Symfony, which was released on November 2015 as long term support version of Symfony. See the tag for general Symfony 2.x questions.

The 2.8.0 version was released the 30th November 2015.

Symfony 2.8 is the last version of the Symfony 2.x branch.

Living on the edge

There are a set of interesting links on the symfony blog about what's new in this version:

612 questions
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
48
votes
8 answers

How to get the current logged User in a service

In Symfony 2.8/3.0, with our fancy new security components, how do I get the currently logged User (i.e. FOSUser) object in a service without injecting the whole container? Is it even possible in a non-hacky way? PS: Let's not consider the "pass it…
xDaizu
  • 1,051
  • 1
  • 12
  • 29
27
votes
2 answers

Symfony 2.7 / 3 - Doctrine: You have requested a non-existent service "fos_user.doctrine_registry"

Doing a composer update today suddenly getting the following error: [Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException] You have requested a non-existent service "fos_user.doctrine_registry". when composer is executing…
ken
  • 399
  • 1
  • 3
  • 6
26
votes
3 answers

Generating forms with Symfony 2.8 throws a Twig_Error_Runtime

Since the last LTS version of Symfony was released few days ago (30.11.2015) I started playing with it. Unfortunately I can't generate a CRUD with write actions with the same code that works fine in Symfony 2.7.7. First I create a new Symfony…
cezar
  • 11,616
  • 6
  • 48
  • 84
13
votes
2 answers

How to customize form field based on user roles in Symfony2/3?

Is there a correct way to customize a form depending on the role of the user that requests it? My scenario is pretty simple: I need to hide some fields if the user has not the ROLE_ADMIN granted. I tried to avoid the field display on Twig, but {%…
sentenza
  • 1,608
  • 3
  • 29
  • 51
11
votes
6 answers

Symfony 2 - fetch the last inserted row from table

How can I rewrite this code in order to get last inserted record from the table? $repository = $entityManager->getRepository('AdminBundle:MyTable'); $product = $repository->find($id); I tried something…
Jacek717
  • 139
  • 1
  • 2
  • 12
11
votes
1 answer

Twig_Environment in Service Class leads to DIC RuntimeExtension only when unittesting in Symfony 2.8

I use Twig_Environment to render html mails to be sent. I have a NotificationService Class which is used by other services to send those mails. In a normal usage, everything is working, but since updating to 2.8 the unittest fail…
Rufinus
  • 29,200
  • 6
  • 68
  • 84
9
votes
2 answers

Class constraint validator in form type class?

In the documentation it lists examples for applying a class validation constraint to Annotations, XML and YAML but not for PHP. Since the validation is not applied to a property, where do I add this class validation constraint to the whole class…
Tek
  • 2,888
  • 5
  • 45
  • 73
9
votes
2 answers

Symfony 2.8 dynamic ChoiceType options

in my project I have some forms with choice types with a lot of options. So I decided to build an autocomplete choice type based on jquery autocomplete, which adds new