Flag of Ukraine
SymfonyCasts stands united with the people of Ukraine

Upgrade to Symfony 4.0

Video not working?

It looks like your browser may not support the H264 codec. If you're using Linux, try a different browser or try installing the gstreamer0.10-ffmpeg gstreamer0.10-plugins-good packages.

Thanks! This saves us from needing to use Flash or encode videos in multiple formats. And that let's us get back to making more videos :). But as always, please feel free to message us.

With the deprecations gone... yeah! It's time to upgrade to Symfony 4! If you were hoping this was going to be really cool and difficult... sorry. It's super easy... well... mostly easy.

Open composer.json and change symfony/symfony to ^4.0. There are a few other libraries that start with symfony/, but they're independent and follow different release cycles. Oh, except for symfony/phpunit-bridge: change that to ^4.0 also.

68 lines composer.json
... lines 1 - 15
"require": {
... line 17
"symfony/symfony": "^4.0",
... lines 19 - 30
},
"require-dev": {
... line 33
"symfony/phpunit-bridge": "^4.0",
... lines 35 - 36
},
... lines 38 - 68

Let's do this! Find your terminal and run:

composer update

Yep, upgrading is just that easy! Except... there are almost definitely some libraries in our composer.json file that are not yet compatible with Symfony 4. The best way to find out is just to try it! And then wait for an explosion!

Removing Alice

Ah! Here is our first! Look closely... this is coming from nelmio/alice: the version in our project is not compatible with Symfony 4. If we did some digging, we would find out that there is a new version of Alice that is compatible. But, that version also contains a lot of changes to Alice... and I don't like the library's new version very much. At least, not at this moment.

So, instead of upgrading, remove alice from composer.json. This will break our fixtures: we'll fix them later.

Update again!

composer update

Removing Outdated Libraries

Our next explosion! This comes from incenteev/composer-parameter-handler. This library helps you manage your parameters.yml file and... guess what? When we finish upgrading, that file will be gone! Yep, we do not need this library anymore.

Remove it from composer.json. Oh, also remove the distribution bundle: it helps support the current directory structure, and isn't needed with Flex. And below, remove the generator bundle. We'll install the new MakerBundle later.

Ok, update again!

composer update

When a Library is not Ready: StofDoctrineExtensionsBundle

It works! I'm just kidding - it totally exploded again. This time the culprit is StofDoctrineExtensionsBundle: the version in our project is not compatible with Symfony

  1. Now... we become detectives! Maybe the library supports it in a new version? Let's find out.

Google for StofDoctrineExtensionsBundle to find its GitHub page. Check out the composer.json file. It does support Symfony 4! Great! Maybe there's a new version that has this! Check out the releases. Oof! No releases for a long, long time.

This means that Symfony 4 support was added, but there is not yet a release that contains that code. Honestly, by the time you're watching this, the bundle probably will have a new release. But this is likely to happen with other libraries.

Actually, another common problem is when a library does not have Symfony 4 support, but there is an open pull request that adds it. In both situations, we have a problem, and you have a choice to make.

First... you can wait. This is the most responsible decision... but the least fun. I hate waiting!

Second, if there is a pull request, you can use that fork as a custom composer repository and temporarily use that until the library merges the pull request and tags a release. For example, imagine this pull request was not merged. We could add this as a vcs repository in composer.json, and then update the version constraint to dev-master, because the branch on the fork is master.

And third, since the pull request is merged, but there is no tag, we can simply change our version to dev-master. Believe me: I am not happy about this. But I'll update it later when there is a release.

70 lines composer.json
... lines 1 - 15
"require": {
... lines 17 - 27
"stof/doctrine-extensions-bundle": "dev-master"
},
... lines 30 - 70

Try to update again:

composer update

Ha! Look! It's actually working! Say hello to our new Symfony 4 app! Woohoo!

Upgrading old Packages

Oh, but check out that warning: the symfony/swiftmailer-bridge is abandoned. I don't like that! Hmm, I don't see that package in our composer.json file. Run:

composer why symfony/swiftmailer-bridge

Ah! It's required by symfony/swiftmailer-bundle. We're using version 2.3.8, which is apparently compatible with Symfony 4. But I wonder if there's a newer version?

Tip

Actually, version 2.3.8 is not compatible with Symfony 4. But due to an old issue with its composer.json file, it appears compatible. Be careful with old libraries!

Google for the package to find its GitHub page. Click releases.

Woh! There is a new version 3 of the bundle. And I bet it fixes that abandoned packages issue. Change our version to ^3.1.

70 lines composer.json
... lines 1 - 15
"require": {
... lines 17 - 21
"symfony/swiftmailer-bundle": "^3.1",
... lines 23 - 28
},
... lines 30 - 70

And now, update!

composer update

Because we're upgrading to a new major version, you'll want to check out the CHANGELOG on the project to make sure there aren't any major, breaking changes.

Yes! Abandoned package warning gone! And our project is on Symfony 4. Not bad!

But... get ready... because now the real work starts. And the fun! It's time to migrate our project to the Flex project structure!

Leave a comment!

34
Login or Register to join the conversation
Gregory B. Avatar
Gregory B. Avatar Gregory B. | posted 4 years ago

Hello Ryan, could you tell us what PhpStorm plugin gives you the autocompletion on release versions of composer packages in composer.json ?

1 Reply

Hey Gregory Berger

There is a plugin for PhpStorm for composer support, it's called "PHP Composer.json support"

Cheers!

1 Reply
Gregory B. Avatar

I just installed it, I'll give it a try. Thank you very much!

1 Reply
Fox C. Avatar

Also, do you guys provide mentoring or code review, for instance 15 minutes for $30USD? It really sucks being a solo developer and I could use some help :-(

Reply
Default user avatar
Default user avatar Muhamed Didovic | Fox C. | posted 1 year ago

Hey Cameron, if you still any help contact me: muhamed.didovic@gmail.com

Reply

Hey Cameron

I know that feeling. Can you drop me a message to diego@symfonycasts.com

Cheers!

Reply
Fox C. Avatar

Hi Ryan, I'm getting a strange issue I wondered if you could help with:

Cannot autowire service "Twencha\Bundle\EventRegistrationBundle\Form\Registration\BaseRegistrationType": argument "$kernelEnv" of method "VisageFour\Bundle\ToolsBundle\Form\BaseFormType::__construct()" has no type-hint, you should configure its value explicitly.

However this is an abstract class firstly and secondly, the class isn't used as a service. I don't want to create a service definition for an abstract class! I also don't want to have to add this class to an "excludes" list as it shouldn't be trying to create a service. I cannot find any instances of it being used as a service and from what you said, only classes that are injected are put into the compiler. What should I do?

Reply

Hey Cameron

If both classes BaseFormType and BaseRegistrationType are abstract classes and nobody is using or inheriting from them, then everything should work well. Can you double check that there isn't any "concrete" class extending from one of those?
git grep "BaseFormType\|BaseRegistrationType should do the trick

Cheers!

Reply
Fox C. Avatar

Thanks, I searched my project - yes there are classes that extend these abstract classes. However, from my understanding, that's the point: to not be forced to create service definitions for abstract classes, but to create them for their children classes - I'm not sure why symfony would want to create a service for an un-instantiated abstract class, it's very strange.

Reply

Hey Cameron!

This is a fascinating area of Symfony :). It *does* seem strange that Symfony would register an abstract class as a service. But it's done this way on purpose: someone could (in theory) use this "service auto-registration" feature to register an entire directory of abstract classes as abstract services:


App\AbstractStuff:
resource: '../src/AbstractStuff'
abstract: true

That's a *total* edge case, but it's valid.

But, back to your situation :). Because, even if the above is valid, it is *super* annoying that you would have this abstract class that is causing an error. Here's the trick: here's how this "should" be working internally in Symfony:

A) Symfony sees your class and registers it as a service
B) Some argument can't be autowired, so Symfony "attaches" an error to the service (it does not throw it... yet)
C) Symfony now notices that nobody ever *uses* your service, and so it *removes* it from the container
D) Symfony does not throw the exception from (B) because the service was removed from the container

And this happens all the time - it's why you could create a "model" class (e.g. src/Model/ProductInfo.php) with required constructor arguments and not get an error: this isn't *meant* to be a service, so you never use it as a service, so Symfony realizes it is not actually a service and removes it.

So the question is: why/what is "using" your BaseRegistrationType? You've already said that you are not using it as a service, and I believe you. But... Symfony is using it as a service. Because your form class ultimately implements FormTypeInterface::class, "autoconfigure" is automatically adding a form.type tag - thanks to this line in the core - https://github.com/symfony/...

This ultimately means that Symfony's form system keeps a "reference" to your BaseRegistrationType service, which is not what you want. Honestly, I'm a bit surprised that I've never run into this or heard anyone running into this problem before. There are absolutely ways to work around this, but it *is* (I agree) an odd behavior (this auto-registration, autoconfigure stuff is tricky!). Unfortunately, unless I'm not seeing something, a work-around will be required. I can see 2 options:

1) Exclude the file like you originally suggested. Not ideal, but it will work
2) At the bottom of your services file, override the service and add abstract: true.

Anyways, I hope this helps at least clarify why you're seeing this odd behavior.

Cheers!

Reply
Fox C. Avatar

Thanks for the feedback, I've found a workaround, but as it's something you haven't seen before, I've included the output from Diego's command below - not sure if it's useful, in identfying / confirming the issue, but thought I'd include it anyway if you find it helpful. Thanks for the help.

[username_goes_here]@penguin:~/php/twenchaLE$ git grep "BaseFormType\|BaseRegistrationType"
app/config/services.yml: Twencha\Bundle\EventRegistrationBundle\Form\Registration\BaseRegistrationType:
src/Twencha/Bundle/EventRegistrationBundle/Classes/RegistrationPages/RegistrationPage.php:use Twencha\Bundle\EventRegistrationBundle\Form\Registration\BaseRegistrationType;
src/Twencha/Bundle/EventRegistrationBundle/Classes/RegistrationPages/RegistrationPage.php: * @return BaseRegistrationType
src/Twencha/Bundle/EventRegistrationBundle/Form/BadgeValidationType.php:use VisageFour\Bundle\ToolsBundle\Form\BaseFormType;
src/Twencha/Bundle/EventRegistrationBundle/Form/BadgeValidationType.php: * (Refer to the BaseFormType for more information on formType versions and how-to)
src/Twencha/Bundle/EventRegistrationBundle/Form/BadgeValidationType.php: * - check the BaseFormType for:
src/Twencha/Bundle/EventRegistrationBundle/Form/BadgeValidationType.php: * - create a service definition (use the sample code from the BaseFormType class or from the apps services.yml)
src/Twencha/Bundle/EventRegistrationBundle/Form/BadgeValidationType.php: * - check if any baseForm changes have been made and if so, create and document new version number of the form class in the BaseFormType
src/Twencha/Bundle/EventRegistrationBundle/Form/BadgeValidationType.php:class BadgeValidationType extends BaseFormType
src/Twencha/Bundle/EventRegistrationBundle/Form/EmailSignInType.php:use VisageFour\Bundle\ToolsBundle\Form\BaseFormType;
src/Twencha/Bundle/EventRegistrationBundle/Form/EmailSignInType.php: * for information on form versions and how-to, refer to BaseFormType
src/Twencha/Bundle/EventRegistrationBundle/Form/EmailSignInType.php:class EmailSignInType extends BaseFormType
src/Twencha/Bundle/EventRegistrationBundle/Form/PersonType.php:use VisageFour\Bundle\ToolsBundle\Form\BaseFormType;
src/Twencha/Bundle/EventRegistrationBundle/Form/PersonType.php: * for information on form versions and how-to, refer to BaseFormType
src/Twencha/Bundle/EventRegistrationBundle/Form/PersonType.php:class PersonType extends BaseFormType
src/Twencha/Bundle/EventRegistrationBundle/Form/Registration/BaseRegistrationType.php:use VisageFour\Bundle\ToolsBundle\Form\BaseFormType;
src/Twencha/Bundle/EventRegistrationBundle/Form/Registration/BaseRegistrationType.php:abstract class BaseRegistrationType extends BaseFormType implements RegistrationFormTypeInterface
src/Twencha/Bundle/EventRegistrationBundle/Form/Registration/RegistrationBasicsType.php:use VisageFour\Bundle\ToolsBundle\Form\BaseFormType;
src/Twencha/Bundle/EventRegistrationBundle/Form/Registration/RegistrationBasicsType.php: * (Refer to the BaseFormType for more information on BaseFormType versions and how-to)
src/Twencha/Bundle/EventRegistrationBundle/Form/Registration/RegistrationBasicsType.php:class RegistrationBasicsType extends BaseRegistrationType
src/Twencha/Bundle/EventRegistrationBundle/Form/Registration/RegistrationLanguagesType.php:use VisageFour\Bundle\ToolsBundle\Form\BaseFormType;
src/Twencha/Bundle/EventRegistrationBundle/Form/Registration/RegistrationLanguagesType.php: * (Refer to the BaseFormType for more information on BaseFormType versions and how-to)
src/Twencha/Bundle/EventRegistrationBundle/Form/Registration/RegistrationLanguagesType.php:class RegistrationLanguagesType extends BaseRegistrationType
src/Twencha/Bundle/EventRegistrationBundle/Form/Registration/RegistrationWelcomeType.php: * (Refer to the BaseFormType for more information on BaseFormType versions and how-to)
src/Twencha/Bundle/EventRegistrationBundle/Form/Registration/RegistrationWelcomeType.php: * - check the BaseFormType for:
src/Twencha/Bundle/EventRegistrationBundle/Form/Registration/RegistrationWelcomeType.php: * - DEPRECATED AFTER SYMFONY 3.0 (due to auto-wiring): create a service definition (use the sample code from the BaseFormType class or from the apps services.yml)
src/Twencha/Bundle/EventRegistrationBundle/Form/Registration/RegistrationWelcomeType.php: * - check if any baseForm changes have been made and if so, create and document new version number of the form class in the BaseFormType
src/Twencha/Bundle/EventRegistrationBundle/Form/Registration/RegistrationWelcomeType.php:class RegistrationWelcomeType extends BaseRegistrationType
src/Twencha/Bundle/EventRegistrationBundle/Interfaces/RegistrationFormTypeInterface.php:use VisageFour\Bundle\PersonBundle\Interfaces\BaseFormTypeInterface;
src/Twencha/Bundle/EventRegistrationBundle/Interfaces/RegistrationFormTypeInterface.php:interface RegistrationFormTypeInterface extends BaseFormTypeInterface

Reply
Fox C. Avatar

FYR: (abstract) class: BaseRegistrationType inherits from BaseFormType

Reply
Abdallah O. Avatar
Abdallah O. Avatar Abdallah O. | posted 2 years ago

Hello SymfonyCasts Team, i know it's 2 years now, and i red that HHVM is dropped in symfony4, so i got this 2 problems :
1-This package requires php >=7.3.3 but your HHVM version does not satisfy that requirement, migrating to symfony4.
2- The requested package symfony/symony could not be found in any version, there may be a typo in the package name.
I don't know where to find HHVM.

Reply

Hey Ouahib Abdallah

1.- I have no any particular experience in HHVM but you will have to pump up your PHP version of your machine somehow
2.- Since Symfony4 you don't install symfony/symfony package anymore, you just install the components or bundles that you will need. I recommend you to read about Symfony Flex so you get a better idea of what I'm talking about (https://symfony.com/doc/cur...

Cheers!

Reply
Abdallah O. Avatar

Thank You for replying quickly, i have php version 7.3, i will search for HHVM solution in xamp direction . Thanks

1 Reply
Default user avatar
Default user avatar Mark Bateman | posted 3 years ago

I'm at the part where I changed the Symfony version and php bridge to 4.0 and I keep getting.

$ composer update


Loading composer repositories with package information

Updating dependencies (including require-dev)

Your requirements could not be resolved to an installable set of packages.




Problem 1

- Conclusion: don't install symfony/symfony v4.2.4

- Conclusion: don't install symfony/symfony v4.2.3

- Conclusion: don't install symfony/symfony v4.2.2

- Conclusion: don't install symfony/symfony v4.2.1

- Conclusion: don't install symfony/symfony v4.2.0

- Conclusion: don't install symfony/symfony v4.1.11

- Conclusion: don't install symfony/symfony v4.1.10

- Conclusion: don't install symfony/symfony v4.1.9

- Conclusion: don't install symfony/symfony v4.1.8

- Conclusion: don't install symfony/symfony v4.1.7

- Conclusion: don't install symfony/symfony v4.1.6

- Conclusion: don't install symfony/symfony v4.1.5

- Conclusion: don't install symfony/symfony v4.1.4

- Conclusion: don't install symfony/symfony v4.1.3

- Conclusion: don't install symfony/symfony v4.1.2

- Conclusion: don't install symfony/symfony v4.1.1

- Installation request for phpunit/phpunit ^4.1 -> satisfiable by phpunit/phpunit[4.1.0, 4.1.1, 4.1.2, 4.1.3, 4.1.4, 4.1.5, 4.1.6, 4.2.0, 4.2.1, 4.2.2, 4.2.3, 4.2.4, 4.2.5, 4.2.6, 4.3.0, 4.3.1, 4.3.2, 4.3.3, 4.3.4, 4.3.5, 4.4.0, 4.4.1, 4.4.2, 4.4.3, 4.4.4, 4.4.5, 4.5.0, 4.5.1, 4.6.0, 4.6.1, 4.6.10, 4.6.2, 4.6.3, 4.6.4, 4.6.5, 4.6.6, 4.6.7, 4.6.8, 4.6.9, 4.7.0, 4.7.1, 4.7.2, 4.7.3, 4.7.4, 4.7.5, 4.7.6, 4.7.7, 4.8.0, 4.8.1, 4.8.10, 4.8.11, 4.8.12, 4.8.13, 4.8.14, 4.8.15, 4.8.16, 4.8.17, 4.8.18, 4.8.19, 4.8.2, 4.8.20, 4.8.21, 4.8.22, 4.8.23, 4.8.24, 4.8.25, 4.8.26, 4.8.27, 4.8.28, 4.8.29, 4.8.3, 4.8.30, 4.8.31, 4.8.32, 4.8.33, 4.8.34, 4.8.35, 4.8.36, 4.8.4, 4.8.5, 4.8.6, 4.8.7, 4.8.8, 4.8.9].

- Conclusion: don't install symfony/symfony v4.1.0

- Conclusion: don't install symfony/symfony v4.0.15

- Conclusion: don't install symfony/symfony v4.0.14

- Conclusion: don't install symfony/symfony v4.0.13

- Conclusion: don't install symfony/symfony v4.0.12

- Conclusion: don't install symfony/symfony v4.0.11

- Conclusion: don't install symfony/symfony v4.0.10

- Conclusion: don't install symfony/symfony v4.0.9

- Conclusion: don't install symfony/symfony v4.0.8

- Conclusion: don't install symfony/symfony v4.0.7

- Conclusion: don't install symfony/symfony v4.0.6

- Conclusion: don't install symfony/symfony v4.0.5

- Conclusion: don't install symfony/symfony v4.0.4

- Conclusion: don't install symfony/symfony v4.0.3

- Conclusion: don't install symfony/symfony v4.0.2

- Conclusion: don't install symfony/symfony v4.0.1

- symfony/symfony v4.0.0 conflicts with roave/security-advisories[dev-master].

- symfony/symfony v4.0.0 conflicts with roave/security-advisories[dev-master].

- Installation request for symfony/symfony ^4.0 -> satisfiable by symfony/symfony[v4.0.0, v4.0.1, v4.0.10, v4.0.11, v4.0.12, v4.0.13, v4.0.14, v4.0.15, v4.0.2, v4.0.3, v4.0.4, v4.0.5, v4.0.6, v4.0.7, v4.0.8, v4.0.9, v4.1.0, v4.1.1, v4.1.10, v4.1.11, v4.1.2, v4.1.3, v4.1.4, v4.1.5, v4.1.6, v4.1.7, v4.1.8, v4.1.9, v4.2.0, v4.2.1, v4.2.2, v4.2.3, v4.2.4].

- Installation request for roave/security-advisories dev-master -> satisfiable by roave/security-advisories[dev-master].

Reply

Hey Mark,

Is it the full output you have? What PHP version do you have? You can check it with "$ php --version" in your terminal. Also, could you show us your dependencies in composer.json?

Cheers!

Reply
Kaizoku Avatar
Kaizoku Avatar Kaizoku | posted 4 years ago

friendsofsymfony/user-bundle (v2.0) is not compatible yet with SF4.
After doing the way that Ryan suggest for doctrine extension bundle it's working.
Also I noticed that it's Ryan was a major players into refactoring FOS userbundle for SF4 so it should be soon 'composer ready'.
Thank Ryan btw.

So use this line will make your project good to go : "friendsofsymfony/user-bundle": "dev-master"

Reply

Hey kaizoku!

Thanks for sharing this :). Yea, I hope FOSUserBundle will be Symfony 4 compat VERY soon - all (or at least most) of the work is done as you correctly saw. Workarounds suck, but yep, you've posted the correct workaround for now!

Cheers!

Reply
Trafficmanagertech Avatar
Trafficmanagertech Avatar Trafficmanagertech | posted 4 years ago

Hi, I have a problem...
I need php-ffmpeg/php-ffmpeg, which require neutron/temporary-filesystem, which allows only symfony/filesystem: ^2.3 || ^3.0
How could I solve?
(PHP-FFMpeg was required by pulse00/ffmpeg-bundle, which I already forked to allow SF4)

Reply
Trafficmanagertech Avatar
Trafficmanagertech Avatar Trafficmanagertech | Trafficmanagertech | posted 4 years ago

Fixed by forking also neutron/temporary-filesystem and alchemy/binary-driver :)

Reply

Hey the_nuts!

Great job on solving this. But BOOOO for needing this :). I hope more and more libraries will start supporting Symfony4! Actually, someone just opened a PR (https://github.com/romainne... - is that you? If so, nice work!

Cheers!

1 Reply
Default user avatar
Default user avatar toporovvv | posted 4 years ago

At the moment I have to change php version in config -> platform -> php section from 5.5.9 to 7.2.5. Then, changed a version of Doctrine ORM to "~2.4,>=2.4.5" (found it here
https://github.com/symfony/... ). stof/doctrine-extensions-bundle is fine now, so it stays as is. The whole composer.json for successful update for this tutorial:

 
{
"name": "symfony/framework-standard-edition",
"license": "MIT",
"type": "project",
"description": "The \"Symfony Standard Edition\" distribution",
"autoload": {
"psr-4": { "": "src/" },
"classmap": [ "app/AppKernel.php", "app/AppCache.php" ]
},
"autoload-dev": {
"psr-4": { "Tests\\": "tests/" },
"files": [ "vendor/symfony/symfony/src/Symfony/Component/VarDumper/Resources/functions/dump.php" ]
},
"require": {
"php": ">=5.5.9",
"doctrine/doctrine-bundle": "^1.6",
"doctrine/doctrine-cache-bundle": "^1.2",
"doctrine/doctrine-migrations-bundle": "^1.2",
"doctrine/orm": "~2.4,>=2.4.5",
"knplabs/knp-markdown-bundle": "^1.5",
"sensio/framework-extra-bundle": "^3.0.2",
"stof/doctrine-extensions-bundle": "^1.2",
"symfony/monolog-bundle": "^3.0.2",
"symfony/polyfill-apcu": "^1.0",
"symfony/swiftmailer-bundle": "^3.1",
"symfony/symfony": "^4.0",
"twig/twig": "^1.0||^2.0"
},
"require-dev": {
"doctrine/doctrine-fixtures-bundle": "^2.3",
"symfony/phpunit-bridge": "^4.0"
},
"scripts": {
"symfony-scripts": [
"Incenteev\\ParameterHandler\\ScriptHandler::buildParameters",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::clearCache",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installAssets",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installRequirementsFile",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::prepareDeploymentTarget"
],
"post-install-cmd": [
"@symfony-scripts"
],
"post-update-cmd": [
"@symfony-scripts"
]
},
"config": {
"platform": {
"php": "7.2.5"
},
"sort-packages": true
},
"extra": {
"symfony-app-dir": "app",
"symfony-bin-dir": "bin",
"symfony-var-dir": "var",
"symfony-web-dir": "web",
"symfony-tests-dir": "tests",
"symfony-assets-install": "relative",
"branch-alias": {
"dev-master": "3.2-dev"
}
}
}

Reply

Hey toporovvv ,

Yes, you're right about PHP 7! Well, actually, Symfony 4 requires PHP ^7.1.3, but you have to point platform PHP version to that version you have on production. We just do not have this platform PHP version in our composer.json, but your comment may be useful for people who has. Thanks for sharing it!

Cheers!

1 Reply

Hey weaverryan!

New version is out of stof/doctrine-extensions-bundle. Release is 1.3.0 :)

Cheers!

Reply

Hey niumis

Thanks for informing us, I'll ping Ryan about it :)

Cheers!

Reply
Thomas L. Avatar
Thomas L. Avatar Thomas L. | posted 4 years ago

Hi Ryan, thanks a lot for the great upgrade tutorial!

For me, I don'nt know exactly when it happened first, the cache is broken and it seems to have created an memory leak. If composer is starting clear:cache command the memory usage explode while creating the warmup-cache. I tried it on my local xampp-installation with 8GB Ram and with dev-server with 16GB RAM same issue. My next step was to check the memory_limit. This is fine to.

Do you have any hints how to debug/solve this?

Regards,
Thomas

Reply

Hey Thomas,

Yes, good step about checking memory limit, so what memory limit do you have? Here's some recommendations from Composer which probably can help: https://getcomposer.org/doc... - it worked for me. Also, do you have Xdebug installed? Did you disabled it during installation? See https://getcomposer.org/doc... . I'd also recommend you to upgrade to the latest Composer version available, I see it's 1.6.2.

Let us know if it does not help

Cheers!

Reply
Thomas L. Avatar

Hi Victor,

thanks for suggestions. On DEV machine the memory limit for CLI is disabled and we increased the memory to 32G. Composer is neweset version. xdebug is installed and suggestions did not help also.

So now I've started from scratch with a new symfony 4 installation and copy related project files one by one and test results. What I saw while profiling is an heavy increase of nested functions while compiling cache. I've set value to 10000 (! default is 256 i mention !) and same issue. I mention that there is sleeping anywhere a small bug in symfony 4 code but I am not sure how to find him.

For now I will continue with my workaround above and maybe I can reproduce the behaviour and have more clue what file/function/class is causing this one.

Reply

Hey Thomas

How much swap memory do you have available? I experienced a somehow similar problem like this one in the past, and I managed to fix it by increasing the swap memory to 4GB

I hope it helps you. Cheers!

Reply
Thomas L. Avatar

Hi Diego Aguiar,

2G swap but this is not the cause. If 32G RAM are fully used there must be another issue. I copied yesterday non-symfony-files (only my projectfiles) without configuration to a from-scratch-installation and tried it step by step to fullfill the configuration I need. And ... no issue. I have no clear whats going on but for now thats by dirthy workaround.

Reply

Hey Thomas!

That IS very strange and concerning.... and it *is* totally possible there's some sleeping bug in Symfony. I have a recommendation: try profiling with blackfire. You can even use Blackfire to profile a command you run at the command line: https://blackfire.io/docs/c.... I've done this many times, and it works awesome. THIS would be the way to find out what's causing the huge memory. I'd be very interested in knowing :).

Cheers!

Reply
Thomas L. Avatar

HI Ryan, thanks a lot for giving this hint. I requested an trial this morning.

Reply

Great! Let us know how it went :)

Have a nice day

Reply
Cat in space

"Houston: no signs of life"
Start the conversation!

What PHP libraries does this tutorial use?

// 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
    }
}