Questions tagged [symfony4]

Symfony is a PHP framework developed by SensioLabs. Symfony 4 was released in November 2017.

Symfony is a PHP web framework first released in July 2011 and was created by SensioLabs. Symfony 4 was released in November 2017. The latest LTS is 4.4.8 released in November 2019 and has support until 2022.

Differences from Symfony 3

  • Symfony Flex automates many of the tasks that previously had to be done manually - it’s based on Symfony Recipes, which are a set of automated instructions.
  • Version 4 also recommends a bundle-less setup, e.g. putting many of the source files directly in /src instead of something like /src/AppBundle.
  • Installing using the Symfony skeleton will create a relative small version of the app. Additional packages need to be added. A more fully-featured version (more similar to the »Symfony Standard Edition« in Symfony 3) is available with the Symfony Demo Application.
  • Minimum PHP 7.1.3

Documentation / Resources

  • Overview: Documentation for current version.
  • Flex: New way to manage Symfony apps.
  • Best Practices: Best practices for developing web apps, esp. the ones using the full-stack Symfony framework.
  • Symfony Recipes Server: Includes official and community recipes.
4007 questions
10
votes
1 answer

Changing the default App namespace to something else

I'm about to start a new project and I've decided to go with sf4. So first I've created a new sf project composer create-project symfony/skeleton But this time I want to get rid of the default App namespace and change it to a specific, project…
Larusso
  • 129
  • 1
  • 4
9
votes
2 answers

Chrome dev tools Network -> Preview tab not rendering html/css anymore, like Firefox does

Since quite some time ago (probably months) I noticed that Chrome dev tools does not render the html/css correctly anymore. It does render something, but it's not looking great, making it hard to use. This is how it looks in Firefox and how it…
Allart
  • 830
  • 11
  • 33
9
votes
3 answers

Fatal error: Method class@anonymous::__toString() must not throw an exception after composer install

hello I have an error when I do a composer install and which does cache: clear. I use Symfony 4.1 I already delete /var & /vendor I am on Docker (php) composer install Loading composer repositories with package information Installing…
Arnaud Bagnis
  • 142
  • 2
  • 9
9
votes
0 answers

Symfony 4 @Gedmo\SoftDeleteable() for form with collection type form

I have problem with soft delete item with form collection in Symfony framework I want to add and remove items in relation with Symfony form collection, If I remove item from collection this item must soft deleted from relation records with below…
Mortie
  • 390
  • 9
  • 24
9
votes
3 answers

Attempted to load class "DoctrineCacheBundle" from namespace "Doctrine\Bundle\DoctrineCacheBundle"

Can anyone help me, guys? Every time I run the command php bin/console server:run this error occurs: PHP Fatal error: Uncaught Symfony\Component\Debug\Exception\ClassNotFoundException: Attempted to load class "DoctrineCacheBundle" from…
9
votes
1 answer

Service not found: even though it exists in the app's container

What do I have: services.yaml: app.foo.bar: class: App\Foo\Bar arguments: #[ ... ] Controller: use Symfony\Bundle\FrameworkBundle\Controller\Controller; class MyController extends Controller { public function baz(Request $request) …
Tarasovych
  • 2,228
  • 3
  • 19
  • 51
9
votes
2 answers

How to define global variables for Twig templates with values coming from the DB?

I would like to define a global variable for twig, which would be accessible from any template. I can create a global variable in symfony's config/packages/twig.yaml, but I need it to be a value obtained from the database. In the documentation for…
9
votes
2 answers

Symfony 4 Production Mode ErrorHandling Pages Memory Exhausted

I set my project to prod mode in .env and everything aside from the custom error pages seem to work. I have this as my 404 twig template: {# templates/bundles/TwigBundle/Exception/error404.html.twig #} {% include 'builder/layout/header.html.twig'…
treyBake
  • 6,440
  • 6
  • 26
  • 57
9
votes
9 answers

Symfony 4 annotation routing does not work

I just started learning Symfony. I am following this official tutorial exactly. Routing works fine when done with config/routes.yaml, but on using annotations: namespace App\Controller; use Symfony\Component\HttpFoundation\Response; use…
okey_on
  • 2,888
  • 8
  • 28
  • 36
9
votes
1 answer

Annotations in Symfony 4

I try to develop with Symfony 4 so I follow the tutorial on symfony.com I've got an error when I try to access at : http://localhost:8000/ This is the error : [Syntax Error] Expected PlainValue, got ''' at position 7 in method…
N.Jourdan
  • 590
  • 2
  • 4
  • 22
9
votes
3 answers

Including Assets (CSS, JS) in Symfony 4 / Twig Template

Im learning Symfony and trying to set up a boilerplate app in Symfony 4 This Symfony document describes how to include assets in your page, namely using the asset package like so.. Symfony!
yevg
  • 1,846
  • 9
  • 34
  • 70
9
votes
2 answers

Doctrine2 (Symfony4) database connection url over socket

I'm having a hard time getting a database connection to work with the mysql url format used in Symfony4 w/ doctrine2. Here is what I'm trying to do: mysql://dbusername:dbpassword@unix_socket(/path/to/socket)/dbname What am I doing wrong? Please…
Layton Everson
  • 1,148
  • 9
  • 18
9
votes
2 answers

How can I retrieve my environment variables in a parameter file in Symfony4 structure?

I did a fresh Symfony installation by using Symfony Flex and the new skeleton belong to the next Symfony 4 directory structure. I add and configure a first third-party bundle : HWIOAuthBundle. This bundle is used to connect via Twitter using two…
8
votes
7 answers

Attempted to load class "WebProfilerBundle" from namespace "Symfony\Bundle\WebProfilerBundle" when deploying on Heroku using development dependencies

We have a Symfony 4.3 web application hosted on Heroku. This is a new setup and we never managed to have the dev mode to work correctly. There are plenty of similar issues online but none fixes the exact symptoms we are facing here. The project was…
dankilev
  • 720
  • 2
  • 10
  • 32
8
votes
4 answers

How do I suppress the warning "unable to find the application log" after running "symfony serve"?

With Symfony 4.3 and Symfony CLI v4.7.1, when I run: symfony serve I see the following warning in the output: WARNING unable to find the application log How do I solve the issue that raises this warning? Do I have to install the logger bundle?
Geoffrey
  • 5,407
  • 10
  • 43
  • 78