2
  • My problem : Cache Error when upgrading symfony 4.4 to 5.0 (cache clear work on 4.4 )

  • php : 7.2.5 when upgrade, 7.1 before upgrade

  • Before update symfony 4.4 to 5, i've followed this doc (symfony doc 4.4 to 5): https://symfony.com/doc/4.4/setup/upgrade_major.html

  • i've fix all depreciations

  • composer require --dev symfony/phpunit-bridge

  • ./bin/phpunit and fix as many problem as possible, only one left :

        Stack trace:
        #0 [internal function]: array_merge(phpunit/phpunit: Array)
        #1 phar:///usr/local/bin/composer.phar/src/Composer/DependencyResolver/DefaultPolicy.php(84): call_user_func_array('array_merge', Array)
        #2 phar:///usr/local/bin/composer.phar/src/Composer/Command/ShowCommand.php(537): Composer\DependencyResolver\DefaultPolicy->selectPreferredPackages(Object(Composer\DependencyResolver\Pool), Array, Array)
    
    
    

When i execute "composer update "symfony/*"" everythings work except the last part(cache:clear) :

```Executing script cache:clear [KO]
 [KO]
Script cache:clear returned with error code 1
!!
!!   // Clearing the cache for the dev environment with debug
!!   // true
!!
!!
!!  In FileLoader.php line 173:
!!
!!    Class "1\AdminController" does not exist in 
 /Applications/MAMP/htdocs/MyApplication/config/routes/../../src/Controller/ (which is being imported from "/A
!!    pplications/MAMP/htdocs/MyApplication/config/routes/annotations.yaml"). Make s
!!    ure annotations are installed and enabled.
!!
!!
!!  In AnnotationDirectoryLoader.php line 62:
!!
!!    Class "1\AdminController" does not exist
!!
!!
!!  cache:clear [--no-warmup] [--no-optional-warmers] [-h|--help] [-q|--quiet] [-v|vv|vvv|--verbose] [-V|--version] [--ansi] [--no-ansi] [-n|--no-interaction] [-e|--env ENV] [--no-debug] [--] <command>
!!
!!
Script @auto-scripts was called via post-update-cmd
  • There is no 1/AdminController in my Application

  • AdminController is the first Controller in /Admin/

  • If i change ressourse to /HomeController, i got the same error but with 1/HomeController

  • Annotation.yaml :

    controllers
      resource: ../../src/Controller/
      type: annotation
    
    kernel:
      resource: ../../src/Kernel.php
      type: annotation
    
    
  • composer self-update change nothing

  • Here is my Composer.json

  "type": "project",
  "license": "proprietary",
  "require": {
    "php": "^7.2.5",
    "ext-ctype": "*",
    "ext-iconv": "*",
    "composer/package-versions-deprecated": "1.11.99.5",
    "doctrine/annotations": "^1.8",
    "doctrine/common": "^2",
    "doctrine/doctrine-bundle": "^2",
    "doctrine/doctrine-migrations-bundle": "^2",
    "doctrine/orm": "^2",
    "dompdf/dompdf": "^0.8.5",
    "phpdocumentor/reflection-docblock": "^4.3",
    "sensio/framework-extra-bundle": "^5.1",
    "symfony/apache-pack": "^1.0",
    "symfony/asset": "^5.0",
    "symfony/cache": "5.0.*",
    "symfony/config": "5.0.*",
    "symfony/console": "5.0.*",
    "symfony/dotenv": "^5.0",
    "symfony/error-handler": "^5.0",
    "symfony/event-dispatcher": "^5.0",
    "symfony/expression-language": "^5.0",
    "symfony/flex": "^1.3.1",
    "symfony/form": "^5.0",
    "symfony/framework-bundle": "^5.0",
    "symfony/http-client": "^5.0",
    "symfony/http-foundation": "^5.0",
    "symfony/http-kernel": "^5.0",
    "symfony/intl": "^5.0",
    "symfony/mailer": "^5.0",
    "symfony/monolog-bundle": "^3.1",
    "symfony/process": "^5.0",
    "symfony/property-access": "^5.0",
    "symfony/property-info": "^5.0",
    "symfony/security-bundle": "^5.0",
    "symfony/security-core": "^5.0",
    "symfony/security-guard": "^5.0",
    "symfony/security-http": "^5.0",
    "symfony/serializer": "^5.0",
    "symfony/translation": "^5.0",
    "symfony/twig-bundle": "^5.0",
    "symfony/validator": "^5.0",
    "symfony/web-link": "^5.0",
    "symfony/yaml": "^5.0",
    "twbs/bootstrap": "4.4.1",
    "twig/extra-bundle": "^2.12|^3.0",
    "twig/twig": "^2.12|^3.0"
  },
  "require-dev": {
    "doctrine/doctrine-fixtures-bundle": "^3.4.2",
    "fzaninotto/faker": "^1.9",
    "phpunit/phpunit": "^7.5",
    "symfony/browser-kit": "^5.0",
    "symfony/css-selector": "^5.0",
    "symfony/debug-bundle": "^5.0",
    "symfony/maker-bundle": "^1.14",
    "symfony/phpunit-bridge": "^6.1",
    "symfony/stopwatch": "^5.0",
    "symfony/web-profiler-bundle": "^5.0"
  },
  "config": {
    "preferred-install": {
      "*": "dist"
    },
    "platform": {
      "php": "7.2.5"
    },
    "sort-packages": true,
    "allow-plugins": {
      "ocramius/package-versions": true,
      "symfony/flex": true
    }
  },
  "autoload": {
    "psr-4": {
      "App\\": "src/"
    }
  },
  "autoload-dev": {
    "psr-4": {
      "App\\Tests\\": "tests/"
    }
  },
  "replace": {
    "paragonie/random_compat": "2.*",
    "symfony/polyfill-ctype": "*",
    "symfony/polyfill-iconv": "*",
    "symfony/polyfill-php71": "*",
    "symfony/polyfill-php70": "*",
    "symfony/polyfill-php56": "*"
  },
  "scripts": {
    "auto-scripts": {
      "cache:clear": "symfony-cmd",
      "assets:install %PUBLIC_DIR%": "symfony-cmd"
    },
    "post-install-cmd": [
      "@auto-scripts"
    ],
    "post-update-cmd": [
      "@auto-scripts"
    ]
  },
  "conflict": {
    "symfony/symfony": "*"
  },
  "extra": {
    "symfony": {
      "allow-contrib": false,
      "require": "5.0.*"
    }
  }
}


  


 


  
  • Post your annotation.yaml please. – MonTea Jun 16 '22 at 20:12
  • Try to remove the cache by hand with `rm -rf var/cache/*` or/and `composer --no-scripts install` (to handle the installation without the script part)… But I think you don't have to add your specific Controller in the annotations file. You only have to set the folder like: `resource: '../../src/Controller/'` … Symfony automatically adds all Controllers which were found there. – MonTea Jun 18 '22 at 19:00
  • Adding HomeController is just a test to see if it come from AdminController of if its all my controller ^^ rm -rf var/cache/* and composer --no-scripts install work but doesn't fix my problem, i can't clear cache, i still have the same error – Bastien SCHRODER Jun 20 '22 at 09:51

1 Answers1

0

Perhaps you have to remove the composer.lock and symfony.lock and also update symfony/flex to min 1.18 I would prefer 1.19.2 or 2.2.2.

MonTea
  • 1,166
  • 1
  • 13
  • 30
  • It doesn't work, same error after Delete both file , version change for symfony/flex to 1.19.2 and composer install/composer update, cache clear fail again – Bastien SCHRODER Jun 17 '22 at 07:23
  • Sorry if you remove those two files, you should remove the vendor too. Perhaps its a problem that you have sometimes ^5.0 and sometimes 5.0.* in your composer.json – MonTea Jun 17 '22 at 07:54
  • Still doesn't work after delete both file and vendor, cacheclear doesn't work on composer install – Bastien SCHRODER Jun 17 '22 at 09:34