删除Magento 2中的所有缓存后出错


10

在删除所有缓存为

rm -rf var/cache/* var/page_cache/* var/view_preprocessed/* var/generation/*

我低于错误

Warning: ltrim() expects parameter 1 to be string, object given in vendor\magento\framework\Code\Generator\EntityAbstract.php on line 152

Notice: Uninitialized string offset: 0 in vendor\magento\framework\Autoload\ClassLoaderWrapper.php on line 81

Notice: Uninitialized string offset: 0 in vendor\composer\ClassLoader.php on line 317

Notice: Uninitialized string offset: 0 in vendor\composer\ClassLoader.php on line 349
exception 'RuntimeException' with message 'Source class "" for   "Magento\Framework\App\Response\Http\Interceptor" generation does not exist.'
in vendor\magento\framework\Code\Generator.php:185 Stack trace:     #0  
vendor\magento\framework\Code\Generator.php(112): Magento\Framework\Code\Generator->tryToLoadSourceClass('Magento\\Framewo...', Object(Magento\Framework\Interception\Code\Generator\Interceptor)) #1 
vendor\magento\framework\Code\Generator\Autoloader.php(35): Magento\Framework\Code\Generator->generateClass('Magento\\Framewo...') #2 [internal function]: Magento\Framework\Code\Generator\Autoloader->load('Magento\\Framewo...') #3 
vendor\magento\framework\ObjectManager\Factory\AbstractFactory.php(93): spl_autoload_call('Magento\\Framewo...') #4 
vendor\magento\framework\ObjectManager\Factory\Compiled.php(88): Magento\Framework\ObjectManager\Factory\AbstractFactory->createObject('Magento\\Framewo...', Array) #5 
vendor\magento\framework\ObjectManager\Factory\Compiled.php(130): Magento\Framework\ObjectManager\Factory\Compiled->create('Magento\\Framewo...') #6 
vendor\magento\framework\ObjectManager\Factory\Compiled.php(67): Magento\Framework\ObjectManager\Factory\Compiled->get('Magento\\Framewo...') #7     
vendor\magento\framework\ObjectManager\ObjectManager.php(57): Magento\Framework\ObjectManager\Factory\Compiled->create('Magento\\Framewo...', Array) #8 
vendor\magento\framework\App\Bootstrap.php(233): Magento\Framework\ObjectManager\ObjectManager->create('Magento\\Framewo...', Array) #9 
index.php(38): Magento\Framework\App\Bootstrap->createApplication('Magento\\Framewo...') #10 {main}

这个问题背后的原因是什么?

您能建议我解决此问题的方法吗?

Answers:


19

您必须先删除var文件夹。

运行命令, php bin/magento setup:di:compile

删除var文件夹后,授予var文件夹权限,

chmod -R 775 var/generation/ var/cache/ var/full_page/

再检查一遍。


4
使用php bin / magento setup
sagar sapkota,2016年

我有同样的问题,我的问题也使用php bin / magento setup:di:compil comand解决了
Pandurang

6

如果您在编译后仍然遇到问题,通常可以删除var / di文件夹和内容。我不知道是什么真正导致了这种情况的发生,我经常碰到它,并且非常想知道。


1
您是否已经找到原因了?
Stevie G

1

我有同样的问题,我通过赋予var目录777权限来修复它

cd magento root folder
sudo chmod 777 -R var/

现在,Magento可以创建di文件夹。


0

我下面同样的问题对我有用

cd <your Magento install dir> 
find var generated vendor pub/static pub/media app/etc -type f -exec chmod g+w {} +
find var generated vendor pub/static pub/media app/etc -type d -exec chmod g+ws {} +
chown -R :www-data .   // I used LEMP/LAMP
chmod u+x bin/magento

php bin/magento setup:di:compile   // you can skip if know compile status
php bin/magento setup:static-content:deploy -f en_CA // if need your language code
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.