Laravel:具有非复合名称“Cache”的 use 语句无效

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/41441462/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 15:02:58  来源:igfitidea点击:

Laravel: The use statement with non-compound name 'Cache' has no effect

phplaravelcaching

提问by Edgaras Karka

I have centos7php56laravel 5and memcachedbut when try use Cachein routes.phpI get:

我有centos7php56laravel 5memcached但是当我尝试时use Cacheroutes.php我得到:

ErrorException in routes.php line 3:
The use statement with non-compound name 'Cache' has no effect

router.php

路由器.php

<?php

use Cache;
...

回答by Artyom Sokolov

Just remove use Cache;from your routes.php. It is not needed there as file itself is not associated with specific namespace. Once you remove it you will not see that warning again.

删除use Cache 即可;从你的routes.php。由于文件本身与特定的命名空间无关,因此不需要它。删除它后,您将不会再看到该警告。

回答by Daan Meijer

That is because you are already in the global namespace. So when you do something like use Cache;, you are saying "when I say Cache, I mean \Cache". Because you already arein the global namespace, that statement has no effect. That's what the warning is about.

那是因为您已经在全局命名空间中。所以当你做类似的事情时use Cache;,你是在说“当我说缓存时,我的意思是\缓存”。因为你已经在全局命名空间,这种说法没有任何效果。这就是警告的内容。