Reputation: 61
I'm trying to deploy a symfony project following the steps:
./composer.phar update
php bin/console cache:clear
I've also tried to install manually doctrine driver ArrayCache running:
./composer.phar require doctrine/cache
The results is always the same and I end up with the following error:
# ./composer.phar update --no-interaction
[...]
Script cache:clear returned with error code 255
!!
!! In ContainerBuilder.php line 1089:
!!
!! Class Doctrine\Common\Cache\ArrayCache does not exist
!!
!!
!!
Script @auto-scripts was called via post-update-cmd
I'm new with symfony and I'm not able to understand why this class is missing.
I'm using the following versions:
"symfony/framework-bundle": "5.1.*",
"doctrine/doctrine-bundle": "^2.2",
Thanks in advance for your help.
Upvotes: 5
Views: 12856
Reputation: 263
I think you installed doctrine/cache
2.x version when installed "doctrine/doctrine-bundle": "^2.2",
.
From github page:
This library is deprecated and will no longer receive bug fixes from the Doctrine Project. Please use a different cache library, preferably PSR-6 or PSR-16 instead.
So you have next options:
composer require doctrine/cache:^1.11
Upvotes: 12
Reputation: 331
After some time, I found a better solution:
composer require symfony/cache
then in php:
$config = new Configuration;
$queryCache = new PhpFilesAdapter('doctrine_queries'); $config->setQueryCache($queryCache);
$resultCache = new PhpFilesAdapter('doctrine_results', 0, $settings['cache_dir']); $config->setResultCache($resultCache);
$metaCache = new PhpFilesAdapter('doctrine_metadata', 0, $settings['cache_dir']); $config->setMetadataCache($metaCache);
I can now upgrade doctrine to the latest version.
This is somewhere along the line of another answer, but since the documentation is so poor (for non-Symfony user), adding a few lines of php can make all the difference! Hope this helps some people. If this is for some reason not the best solution, I'm eager to hear.
For me the solution is to downgrade to doctrine 2.7.4.
Google'd around and it is obvious that Doctrine does not have its documentation in order. I'll put on my todo-list to look for another (3rd party) cache solution to replace the ArrayCache. I should have done this earlier, since ArrayCache is not suitable for production. Just hope Doctrine updates its documentation soon!
If I find an alternative, I'll post it here. Or perhaps someone else beats me to it, I hope so!
Upvotes: 2
Reputation: 4014
I think it's established in the other answers that somewhere you are instantiating an instance of ArrayCache
from the doctrine/cache package.
If you want equivalent functionality with doctrine/cache 2.x (where ArrayCache
has been removed) you can do what doctrine/dbal itself will do.
I.e. instead of this...
$cache = new \Doctrine\Common\Cache\ArrayCache();
... you may instead do this (assuming you are comfortable introducing the symfony/cache package) ...
$cache = \Doctrine\Common\Cache\Psr6\DoctrineProvider::wrap(
new \Symfony\Component\Cache\Adapter\ArrayAdapter()
)
This is what Doctrine itself does as a fallback when ArrayCache
does not exists and you do not otherwise specify a cache in dev-mode. You can see the logic for how Doctrine decides to instantiate a cache at \Doctrine\ORM\Tools\Setup::createCacheInstance
.
(Note: Even when you do not specify a cache, Doctrine will instantiate one automatically -- it could be storing values in Redis without you even realising 😲)
Upvotes: 2
Reputation: 325
To solve this problem, i first delete the composer.lock file, after, i installed composer with this following command: composer install and I installed the symfony cache dependency with this following command: composer require symfony/cach
->https://packagist.org/packages/symfony/cache
Upvotes: -2