当前位置:首页 > PHP > 正文内容

Lumen框架报错Cannot declare class Event, because the name is already in use

陈杰2年前 (2021-01-07)PHP2873

Lumen框架报错信息

Cannot declare class Event, because the name is already in use

(1/1) ErrorException

Cannot declare class Event, because the name is already in use

in Application.php line 716
at Application->Laravel\Lumen\Concerns\{closure}(2, 'Cannot declare class Event, because the name is already in use', '/www/wwwroot/liao.nnjingfang.com/vendor/laravel/lumen-framework/src/Application.php', 716, array('userAliases' => array(), 'defaults' => array('Illuminate\Support\Facades\Auth' => 'Auth', 'Illuminate\Support\Facades\Cache' => 'Cache', 'Illuminate\Support\Facades\DB' => 'DB', 'Illuminate\Support\Facades\Event' => 'Event', 'Illuminate\Support\Facades\Gate' => 'Gate', 'Illuminate\Support\Facades\Log' => 'Log', 'Illuminate\Support\Facades\Queue' => 'Queue', 'Illuminate\Support\Facades\Route' => 'Route', 'Illuminate\Support\Facades\Schema' => 'Schema', 'Illuminate\Support\Facades\Storage' => 'Storage', 'Illuminate\Support\Facades\URL' => 'URL', 'Illuminate\Support\Facades\Validator' => 'Validator'), 'merged' => array('Illuminate\Support\Facades\Auth' => 'Auth', 'Illuminate\Support\Facades\Cache' => 'Cache', 'Illuminate\Support\Facades\DB' => 'DB', 'Illuminate\Support\Facades\Event' => 'Event', 'Illuminate\Support\Facades\Gate' => 'Gate', 'Illuminate\Support\Facades\Log' => 'Log', 'Illuminate\Support\Facades\Queue' => 'Queue', 'Illuminate\Support\Facades\Route' => 'Route', 'Illuminate\Support\Facades\Schema' => 'Schema', 'Illuminate\Support\Facades\Storage' => 'Storage', 'Illuminate\Support\Facades\URL' => 'URL', 'Illuminate\Support\Facades\Validator' => 'Validator'), 'alias' => 'Event', 'original' => 'Illuminate\\Support\\Facades\\Event'))
at class_alias('Illuminate\\Support\\Facades\\Event', 'Event')in Application.php line 716
at Application->withAliases(array())in Application.php line 683
at Application->withFacades()in app.php line 27
at require('/www/wwwroot/liao.nnjingfang.com/bootstrap/app.php')in index.php line 20


原因是安装了Event扩展,导致Lumen的Event类重名了,修改一下就行了


解决办法 bootstrap/app.php修改以下代码


$app->withFacades();


$app->withFacades(true, [
   \Illuminate\Support\Facades\Event::class => 'LumenEvent',
]);
//$app->withFacades();



问题解决


image.png


扫描二维码至手机访问

扫描二维码推送至手机访问。

版权声明:本文由何烦过虎溪发布,如需转载请注明出处。

转载请注明出处:http://95shouyou.com/?id=31

分享给朋友:

相关文章

lavel对接个推别名推送

lavel对接个推别名推送

新项目采用uniapp开发,需要用到推送功能,之前接过极光,其中的一些坑都踩过了,但是unipush用的是个推的推送,那就只有重写踩坑了。composer  require&nbs...

通过supervisor管理laravel的queue队列

通过supervisor管理laravel的queue队列

配置文件[program:queue]command=php artisan queue:work redis --tries=3 --delay=3directory=/www/wwwroot/sh...

利用workerman实现webrtc实时音视频通话

利用workerman实现webrtc实时音视频通话

实现原理利用workerman的websocket实现实时消息传递。webrtc自带p2p功能,利用STUN中继服务器实现webrtc实时音视频看看我们的前端文件,只是一个单页面<html>...

laravel跨库多态关联实战

laravel跨库多态关联实战

点赞记录表做了分库分表,位于副库里面表结构该点赞表关联了8个不同的表,因为业务原因,评论回复表有四个板块,所以做了4个评论记录表,4个回复记录表,且结构有细微不同。目标是用户获得被点赞记录,根据不同的...

laravel个推设置别名

laravel个推设置别名

上一篇文章我们说过了怎么用laravel接个推的官方sdk实现个推推送和厂商离线推送,因为我们要用到别名推送,而前端又用到的是unipush,在前端去绑定别名的难度肯定要大一点,所以就有一个思路就是,...

Lumen框架报错Class session does not exist

Lumen框架报错Class session does not exist

由于lumen框架是为速度而生的 Laravel 框架,所以移除了session的支持,虽然在ide中代码提示可以敲出Session::put()方法出来,但是最终还是提示的是Class sessio...

发表评论

访客

看不清,换一张

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。