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
10
votes
1 answer

Symfony 4: "Autowire: you should configure its value explicitly."

I'm starting to working with Symfony4 and I meet the following error when I try to run my server: Cannot autowire service "App\Controller\CharacterInformation": argument "$region" of method "__construct()" is type-hinted "string", you should…
user10562377
10
votes
1 answer

Setting no key prefix in symfony4 for redis

I have a problem with proper configuration for redis in Symfony 4. I want to have no prefix before my cache item keys, but it is constantly showing. Here is my config/packages/framework.yaml (part related to cache): cache: prefix_seed: ztw/ztw …
Pawel
  • 135
  • 2
  • 8
10
votes
1 answer

Symfony 4 - Set DateTime

so I've been following this Database and the Doctrine tutorial: https://symfony.com/doc/current/doctrine.html the only difference is that I added a created_ts field to it (among some other fields, but they work fine so no need to go into them). I…
treyBake
  • 6,096
  • 5
  • 22
  • 47
10
votes
2 answers

Is it possible to exclude multiple directories when using Symfony autowire?

When using autowire in Symfony 4 I used this working code: App\: resource: '../src/*' exclude: '../src/{Domain,Entity,Migrations,Tests}' That code excludes from the autowiring all this folders: - src/Domain - src/Entity - src/Migrations -…
Diguin
  • 755
  • 7
  • 16
10
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…
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
  • 107
  • 1
  • 6
9
votes
4 answers

Symfony 4 login form : authenticating successfully, but authentication immediately lost after redirect

I built a login form following this form login setup doc. This is working fine on localhost but not on the production server. On both localhost and prod, authentication begins successfully Guard authentication successful Guard authenticator set…
Kojo
  • 305
  • 9
  • 20
9
votes
4 answers

The lock file is not up to date with the latest changes in composer.json

I'm trying to clone a github repository and issue a composer install on it. But I am getting this: Warning: The lock file is not up to date with the latest changes in composer.json. You may be getting outdated dependencies. Run update to update…
user6313136
  • 187
  • 1
  • 2
  • 7
9
votes
2 answers

Symfony PHPUnit - Inject dependency

I want to test this TokenProvider
Kevin
  • 3,762
  • 4
  • 26
  • 55
9
votes
2 answers

Symfony 4, Postgres - `Invalid value for parameter "client_encoding": "utf8mb4"` on running doctrine command

The Problem I have a fresh setup of postgres 10.5 and symfony 4 application running on php 7.1. But when I try running migration. I keep getting the following Invalid value for parameter "client_encoding": "utf8mb4" error. Steps to reproduce On…
Bikal Basnet
  • 1,452
  • 1
  • 17
  • 27
9
votes
2 answers

Symfony4 "object not found by the @ParamConverter annotation" 404 error

I discover Symfony4 with similar blog sample like describe in https://symfony.com/doc/current/routing.html Then I added a new route to add /blog/about page. So a part of code in my src/Controller/BlogController.php is: /** * @Route("/blog/{id}",…
bcag2
  • 1,131
  • 1
  • 8
  • 20
9
votes
3 answers

Symfony 4 : Override public services in container

I am migrating our project to Symfony 4. In my test suites, we used PHPUnit for functional tests (I mean, we call endpoints and we check result). Often, we mock services to check different steps. Since I migrated to Symfony 4, I am facing this…
Mohammed Mehira
  • 163
  • 1
  • 7
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,096
  • 5
  • 22
  • 47
9
votes
2 answers

Api-Platform: Using Yaml config instead of annotations in SF 4

I'd like to use YAML instead of annotations in Api-Platform. Instead of using the Api-Platform distribution, I have added the api-pack into my existing Symfony Flex project (composer req api). The documentation says the YAML file should take place…
Ben
  • 695
  • 1
  • 5
  • 16
8
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…
Morteza
  • 355
  • 8
  • 22