// composer.json
{
"require": {
"php": "^7.1.3",
"composer/package-versions-deprecated": "^1.11", // 1.11.99
"doctrine/doctrine-bundle": "^1.6", // 1.8.1
"doctrine/doctrine-cache-bundle": "^1.2", // 1.3.2
"doctrine/doctrine-migrations-bundle": "^1.1", // v1.3.1
"doctrine/orm": "^2.5", // v2.7.2
"fzaninotto/faker": "^1.7", // v1.7.1
"knplabs/knp-markdown-bundle": "^1.4", // 1.6.0
"sensio/framework-extra-bundle": "^5.0", // v5.1.3
"stof/doctrine-extensions-bundle": "dev-master", // dev-master
"symfony/asset": "^4.0", // v4.0.1
"symfony/console": "^4.0", // v4.0.1
"symfony/flex": "^1.0", // v1.9.10
"symfony/form": "^4.0", // v4.0.1
"symfony/framework-bundle": "^4.0", // v4.0.1
"symfony/lts": "^4@dev", // dev-master
"symfony/maker-bundle": "^1.0", // v1.0.2
"symfony/monolog-bundle": "^3.1", // v3.1.2
"symfony/polyfill-apcu": "^1.0", // v1.6.0
"symfony/profiler-pack": "^1.0", // v1.0.3
"symfony/security-bundle": "^4.0", // v4.0.1
"symfony/security-csrf": "^4.0",
"symfony/swiftmailer-bundle": "^3.1", // v3.1.6
"symfony/translation": "^4.0", // v4.0.1
"symfony/twig-bundle": "^4.0", // v4.0.1
"symfony/validator": "^4.0", // v4.0.1
"symfony/web-server-bundle": "^4.0", // v4.0.1
"symfony/yaml": "^4.0" // v4.0.1
},
"require-dev": {
"symfony/dotenv": "^4.0", // v4.0.1
"symfony/phpunit-bridge": "^4.0", // v4.0.1
"doctrine/doctrine-fixtures-bundle": "^3.0" // 3.0.2
}
}
19 Comments
Don't know if I missed some forum rule or something, I tried twice with my question and it just gets removed, not sure whether that's automatic or intentionally done by someone. Too much code sample in the question?
Just posted this but it got marked as spam, so I'll try it again 😎
Moving from symfony 3 to 4 I started injecting the service according to this.
Most functions where I inject the "helper" service it works fine, but for some reason it fails on a few of them and I can't figure out what I've done differently... Here's the error:
I've omitted the contents if the functions completely as it doesn't matter what they contain, I can comment out the entire code inside the HistoryIndividualAction() and still get the exact same error message.
The OperatorController::newAction() below works perfectly fine (as well as a number of other functions within the same object), while the OperatorController::HistoryIndividualAction() fails.
The routing looks like this
Services.yml
GlobalHelper starts out like this:
Just posted a question (below). I went to format it a little nicer (adding the PRE tags to the code blocks) and then it got marked as SPAM for some reason...
Moving from symfony 3 to 4 I started injecting the service according to this.
Most functions where I inject the "helper" service it works fine, but for some reason it fails on a few of them and I can't figure out what I've done differently... Here's the error:
<blockquote>Could not resolve argument $helper of "App\Controller\Poslog\OperatorController::historyindividualaction()", maybe you forgot to register the controller as a service or missed tagging it with the "controller.service_arguments"?</blockquote>
I've omitted the contents if the functions completely as it doesn't matter what they contain, I can comment out the entire code inside the HistoryIndividualAction() and still get the exact same error message.
The OperatorController::newAction() below works perfectly fine (as well as a number of other functions within the same object), while the OperatorController::HistoryIndividualAction() fails.
The routing looks like this
# This file is the entry point to configure your own services.
# Files in the packages/ subdirectory configure your dependencies.
# Put parameters here that don't need to change on each machine where the app is deployed
# https://symfony.com/doc/current/best_practices/configuration.html#application-related-configuration
parameters:
services:
GlobalHelper starts out like this:
Hey Mattias,
This problem is unexpected, let's try a few things. First, capitalize your class name
GlobalHelper, double-check that the name of the class match the name of the file (this is just to be compliant with PSR-4)Second, update your
services.yamlconfig. Change it to:We need the service ID to be the FQNS of the class
Give it a try and let me know. Oh, by the way, we use Disqus for the comments and it decided to mark your messages as a spam, possibly due to the length of the comment
Cheers!
Thank you - I found the solution. In the controller, the function name is with a leading capital "H"
public function HistoryIndividualAction
Whereas in the routing yaml file, it is written with a small leading "h"
defaults: { _controller: App\Controller\Poslog\OperatorController::historyIndividualAction }
Changing the routing to
defaults: { _controller: App\Controller\Poslog\OperatorController::HistoryIndividualAction }
fixed the problem =)
Hi, the video only shows a bundle called AppBundle but I have several bundles. Do I have to create a mapping for each bundle?
Hey Antonio S.
Yes, you're correct. You have to map all of your bundles
Cheers!
In a Symfony 3.4 project, I have several bundles in the
srcdirectory. Each of these bundles has aservices.ymlfile and anDependencyInjection/Extensionclass. Some also have aconfig.ymlfile and aDependencyInjection/Configurationclass.Now I'm trying to convert to Symfony 4.3.
Hey halifaxious
You can merge all your
services.ymlfiles intoconfig/services.yaml, or just move them thereconfig/and tell the Kernel to load them:About
config.ymlfiles, those are trickier because you will have to split the configuration into multiple files. For example, if in any of yourconfig.ymlfiles you have something like this.You have to copy the whole block
stof_doctrine_extensionsand move it intoconfig/packages/stof_doctrine_extensions.yamlfileAbout your
DependencyInjectionfiles you can just move them intosrc/DependencyInjectionand it should just work out of the box (just check for name collision)What kind of configuration do you have?
Cheers!
My most problematic internal bundle is HazardBundle. Its services look like this:
There is a config file that I have moved to
/config/packages/hazard.yamlwhich is the source for the%acrd_hazard.pictograms%parameter. The parameter is built in theHazardBundle/DependencyInjection/HazardExtensionclass using theHazardBundle/DependencyInjection/Configurationclass as follows:The
hazard.yamlbegins like this:Before I moved hazard.yaml to /config/packages, my services file failed because the %acrd_hazard.pictogram% parameter was undefined. After I moved it, I got the error "There is no extension able to load the configuration for hazard". Moving
HazardExtensiontosrc/DependencyInjectiondoes not change that.What am I missing?
Ok, so your Extension is not being detected for some reason. Double check its namespace and it should extend from
Symfony\Component\DependencyInjection\Extension\Extension. Also it must live insidesrc/DepedencyInjectionfolderI hope it helps
Hi,
I must have skipped one page, I don't have the config/packages/doctrine.yaml file. I tried "composer require doctrine/doctrine-bundle" which added "doctrine/doctrine-bundle": "^1.9" in my composer.json but nothing else happens. What am I missing here ? How can I install Doctrine in my project ?
Thanks.
Edit : I found that I should use "require symfony/orm-pack" but the console answers "nothing to install or update"
Edit 2 : I deleted the vendor directory then re-ran (?) the previous command. Suddenly 83 installs, including doctrine, and "doctrine.yaml" is now in the packages directory (with several others - previously missing too - like google_recaptcha.yaml). All right, then, I can continue the migration ! I'll be back for many other questions ;)
Hey Jean-tilapin
I'm glad to hear that you could fix your problem, but I believe what happened was that for some reason the doctrine bundle recipe didn't get installed. When that happens, you can run
composer fix-recipesand if it was missing, it will install it for you :)Cheers!
Hi !
I'm actually facing a really weird error, the problem is 99% due to me, but I'm stuck.
First my error is :
In FileLoader.php line 168:
Expected to find class "UTM\CoreBundle\Controller\CoreController" in file "C:\Users\legof\Documents\GitHub\utm-website\src\UTM/CoreBundle\Controller\CoreController.php" while importing services from resource "../src/UTM/*", but it was not found! Check the namespa
ce prefix used with the resource in C:\Users\legof\Documents\GitHub\utm-website\config/services.yaml (which is loaded in resource "C:\Users\legof\Documents\GitHub\utm-website\config/services.yaml").
But I checked it couple times, the file and the namespace are ok.
Here are my services.yaml and the CoreController.php file
Hey Hugo L.
I believe I found your problem, here:
you specified the folder
../src/UTM/Controller, but it actually lives in:../src/UTM/CoreBundle/Controller, isn't it?I think I clearly don't get the utility of the AppBundle lines in services.yaml. I guess it is loading my old code, but I at least don't get how doing it. In my project I have in src folder another folder called UTM where there is 6 bundles (CoreBundle, User Bundle...).
I tried to only load CoreBundle by making the changes you suggested to me but I was facing the same error.
So I removed the "AppBundle" block for the moment and it's working fine, but I guess it is the wrong way to do it.
It would be super cool if you quickly explain me how to do it properly.
Thank you very much !
EDIT:
Ok, I'm now moving my bundles into src, so maybe I do not need anymore those lines. Instead, I have another question, as I said, actually on my src folder I have a UTM folder where there is 6 bundles like this :
src
├───Controller
├───Entity
├───Repository
└───UTM
--├───CoreBundle
--├───FactionBundle
--├───ForumBundle
--├───LimitsBundle
--├───ShopBundle
--└───UserBundle
Now should I move all thoses bundles on src and rename them without the "Bundle" like this (and also remove the Controller, Entity and Repository folder) ?
src
├───Core
├───Faction
├───Forum
├───Limits
├───Shop
└───User
Thank you again
In Symfony4 there is no more a bundle structure, everything lives inside "src" folder (if you check composer.json you will notice that "App" namespace points to the "src" folder), so, yes, you have to move all your files living in bundles into the root of "src", but without deleting "Entity", "Controller", etc. folders, you just have to merge them
After moving the files, you have to double check that all your namespaces did change correctly, and fix any service configuration problem you may face (because all your classes will be automatically registered and configured as services)
Yes, that's what I figured out after this message, that's easier to use and manage at all.
Thank you !
"Houston: no signs of life"
Start the conversation!