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.
3929 questions
36
votes
1 answer

Symfony4 Expected String but got String

I have this error everywhere in my Controller where I "render" or I access a variable through a getParameter: expected "\Symfony\Bundle\FrameworkBundle\Controller\string" got string What's wrong?
Antoine Nedelec
  • 579
  • 6
  • 16
34
votes
3 answers

Cannot autowire service: Argument references class but no such service exists

I'm upgrading a project from Symfony 3 to Symfony 4 (https://github.com/symfony/symfony/blob/master/UPGRADE-4.0.md) and I have many repository/services like this: namespace App\Entity; use App\Entity\Activation; use…
Donal.Lynch.Msc
  • 3,001
  • 12
  • 41
  • 71
33
votes
3 answers

Symfony 4: How to organize folder structure (namely, your business logic)

In the Symfony Best Practices is advised to not use bundles to organize business logic. The bundles should be used only when the code in them is meant to be reused as-is in other applications: But a bundle is meant to be something that can be…
Aerendir
  • 5,365
  • 6
  • 45
  • 85
33
votes
1 answer

Symfony Flex: What does symfony.lock file do?

After installing symfony/serializer I recognized that my symfony.lock file got changed: diff --git a/symfony.lock b/symfony.lock index ba6e23f..bfc391e 100644 --- a/symfony.lock +++ b/symfony.lock @@ -301,5 +301,8 @@ }, "symfony/asset": { …
Chrisissorry
  • 1,199
  • 2
  • 19
  • 35
30
votes
7 answers

How to add Fontawesome 5 to Symfony 4 using Webpack Encore

I want to add Font Awesome 5 to my Symfony 4 project, this is what I did : I added font awesome to my project using yarn : yarn add --dev @fortawesome/fontawesome-free I imported font awesome in my main scss file (assets/css/app.scss) : @import…
sylvain
  • 465
  • 1
  • 6
  • 13
24
votes
5 answers

Using an environment variable (from `.env` file) in custom Twig function in Symfony 4

How can I use an environment variable from the .env file in a custom Twig function (\Twig_SimpleFunction) in Symfony 4?
jpyzio
  • 352
  • 1
  • 3
  • 12
22
votes
6 answers

symfony 4 : How to get "/public" from RootDir

I have an image under the public folder. How can I get my image directory in symfony4 ? In symfony 3, it's equivalent is : $webPath = $this->get('kernel')->getRootDir() . '/../web/';
Mouna Ben Hmida
  • 316
  • 1
  • 4
  • 15
21
votes
4 answers

Symfony 4, get the root path of the project from a custom class (not a controller class)

In the src/Utils directory, I created a custom class Foo for various things. I'm looking for a way to get the absolute root path of the symfony 4 project From a controller, its easy with : $webPath = $this->get('kernel')->getProjectDir(); But…
matthieu lopez
  • 1,558
  • 4
  • 24
  • 61
20
votes
2 answers

Symfony4 Error loading classes custom folder "Expected to find class... but it was not found"

Problem I'm trying to setup a custom directory structure for some shared classes in my Symfony project. I want to create a custom folder in the root of my project and I want to use the Symfony auto-load feature to automatically register services…
Sil
  • 620
  • 1
  • 5
  • 15
17
votes
7 answers

Symfony4: Unable to find the controller for path "/api/login_check". The route is wrongly configured

I am tyring to set up symfony4 api JSON login by JWT. The api platform core bundle is installed and I followed this instruction: https://api-platform.com/docs/core/jwt/ I created the custom user provider as described. By opening the URL…
user3684098
  • 269
  • 2
  • 18
17
votes
5 answers

Symfony 4 is painfully slow in DEV

I try to run a simple Symfony 4 project on a docker container. I have tested regular PHP scripts, and they work very well. But, with Symfony project, the execution gets ridiculously slow. For example, a page without any significant content takes…
user3429660
  • 1,597
  • 3
  • 16
  • 29
17
votes
3 answers

Symfony 4 - Service removed or inlined though it is public

I'm trying to migrate a SF 3.3 app to SF 4 with its new directory structure and everything. I'm struggling on this exception: The "simplethings_entityaudit.reader" service or alias has been removed or inlined when the container was compiled. You…
Ben
  • 695
  • 1
  • 5
  • 16
16
votes
6 answers

Symfony Error: "An exception has been thrown during the rendering of a template"

I am trying to include in my twig file and render it. But it gives me Uncaught PHP Exception Twig_Error_Runtime: "An exception has been thrown during the rendering of a…
Bijaya Basnet
  • 181
  • 1
  • 1
  • 6
16
votes
2 answers

Download PhpSpreadsheet file without save it before

I'm using PhpSpreadsheet to generate an Excel file in Symfony 4. My code is: $spreadsheet = $this->generateExcel($content); $writer = new Xlsx($spreadsheet); $filename = "myFile.xlsx"; $writer->save($filename); // LINE I WANT TO AVOID $response =…
Genarito
  • 1,971
  • 3
  • 17
  • 38
16
votes
4 answers

Generating CRUD in symfony 4

After releasing Symfony 4.0, there is no support for SensioGeneratorBundle. hence the command php app/console generate:doctrine:crud is not available. They suggest to use MakerBundle, but I could not find appropriate replacement for CRUD…
Mahdi
  • 435
  • 3
  • 13
  • 32
1
2 3
99 100