// 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
}
}
10 Comments
I know this is an old video but I recently started working on "Symfony 4.4" application that looks more like a Symfony 3 application, hence the quotes.
This guide is exceptionally helpful on the road to getting my app working with Symfony/flex and all that goodness but I have a question about bundles.
This app has 30 Bundles created back in the day when bundles where the way to go. Also dealing with a Apps folder inside source that also has several bundles. What is a suggested plan of attack
1. Leave the "": namespace? composer is always complaining this is an issue with performance and there are some weird issues with namespaces when it comes to testing as well
2. Create an App base namespace and update everything? this scares me a little and not sure the boffins will like this idea
3. Turn the bundles into packages? Honestly don't know if this is even feasible just throwing it out there
I really want to get this app to point were it actually looks something like a Symfony 4.4 app and not some Frankenstein 3/4 version. There is also the issue with trying to move to Symfony 5, not to mention 6.
Any and all input greatly appreciated
Hey Robert W.
Woh that looks really massive update...
First as a probably fast and much easy solution, I'd like to mention https://github.com/rectorph... . That can really help you with upgrades(however personally I didn't tried it yet).
Or... if you wanna get lot of upgrade experience and solve everything like a pro, then take plan 2! This plan will be the best if you plan future upgrade to Symfony 5/6 and other. Also at the end of upgrade you will get more solid project!
Cheers!
Thanks for the reply and advice Vladimir.
AppBundle is now gone. I have found a new challenge. In my database, I have serialized a few classes. Now, when I try to retrieve those classes and try to excute a method, I get a _php_incomplete_class error because its looking for an 'AppBundle/Entity/ClassName'. It can no longer find the method in the original bundle. Is there a way to fix this?
Hey Scottie,
If I understand you right, when you have AppBundle you serialized a few entities and put them into DB, then refactor your application into bundleless structure and now tries to unserialize them? Yeah, it will throw an error. You need to write a migration command that will unserialize objects by legacy paths, convert them into new objects, serialize them again and store in the DB. But to do this, you would need to keep AppBundle legacy entities structure, so you were able to unserialize them. Then, when you finish migrating, you can safely and completely remove legacy entities.
I hope this helps.
Cheers!
Thank you. That is what I am doing.
Somehow my PhpStorm did not moved all the filed with a new namespace during refactoring. So, easy way for me was to move all the files from AppBundle level up. And then replace all occurrence of AppBundle with App by this script:
(on Linux)
find . -type f -exec sed -i 's/AppBundle/App/g' {} +
(on Mac - here also it could be broken by .DS_store files - just delete them, or execute this script in each directory of src one by one)
find . -type f -exec sed -i "" 's/AppBundle/App/g' {} +
Hey toporovvv
I have experienced troubles perfoming a "move refactoring" on PhpStorm as well, thanks for sharing your workaround, surely more than one will find it useful :)
Cheers!
Hi,
Once again, great tutorial, many thanks.
I have a minor issue however.
Now the namespace begins with App instead of AppBundle, so when I create my User entity, its namespace is obviously App\Entity\User.
But, using Phpstorm (current version is 2018.1) it gives me several warnings about a User class already defined.
The most annoying problem occurs with twig, who doesnt recognized my User attributes (like username or roles ...).
It recognize only the id, and when I ctrl-click on this "id", it brings me to the other App\Entity\User defined :
vendor/symfony/maker-bundle/tests/Util/fixtures/add_one_to_one_relation/User_simple_no_inverse_not_nullable.php
My Phpstorm is yet configured with Symfony plugins and the directory vendor/symfony/maker-bundle is set to "excluded".
I noticed that the Symfony plugins doesn't fully recognize symfony 4 folders, like Translations path (which point to var/cache/dev/translations, but this file seems to not exist anymore)
or the App DIrectory (app folder don't exist as well)
Is there a clean workaround for this ?
Thanks again :)
Hey Chuck norris
Maybe if you kick your computer it will get fixed! (j/k about your nickname)
First of all, the newest PhpStorm version broke some things, so you have to update your plugins, it may fix your problem. Anyways, you have to change "app, web and translations" fields (on your Symfony's plugin configuration) to use the correct values. I hope by doing so it will fix your problems :)
Cheers!
"Houston: no signs of life"
Start the conversation!