When run php artisan the script complains that:
[ErrorException]
Cannot declare class Event, because the name is already in use
The log file lumen.log output:
[2017-10-25 03:22:07] lumen.ERROR: ErrorException: Cannot declare class Event, because the name is already in use in /tmp/lumen/vendor/laravel/lumen-framework/src/Application.php:686
Stack trace:
#0 [internal function]: Laravel\Lumen\Application->Laravel\Lumen\Concerns\{closure}(2, 'Cannot declare ...', '/tmp/lumen/vend...', 686, Array)
#1 /tmp/lumen/vendor/laravel/lumen-framework/src/Application.php(686): class_alias('Illuminate\\Supp...', 'Event')
#2 /tmp/lumen/vendor/laravel/lumen-framework/src/Application.php(654): Laravel\Lumen\Application->withAliases(Array)
#3 /tmp/lumen/vendor/laravel/lumen-framework/src/Application.php(793): Laravel\Lumen\Application->withFacades(true)
#4 /tmp/lumen/vendor/laravel/lumen-framework/src/Console/Kernel.php(55): Laravel\Lumen\Application->prepareForConsoleCommand(true)
#5 [internal function]: Laravel\Lumen\Console\Kernel->__construct(Object(Laravel\Lumen\Application))
[TRUNCATED]
Invocation of dd(Event::class) before calling class_alias alias function outputs
string(19) "Laravel\Lumen\Event"
And when commented out 'Illuminate\Support\Facades\Event' => 'Event', on line 670, artissan seemed to be working.
run php artisan
Try
composer dump-autoload
Hello @hakuno,
Thank you for the suggestion, I did try it and it didn't help.
Regards
@copyrighthero
Really I don't know... But, can you create an empty Lumen project with no problem?
Hello @hakuno,
Thank you for your reply, it seemed that I can create empty lumen under windows machine and am able to use artisan. This problem only happens to me when I create one under linux machine, perhaps it was because my php setup?
Thank you for your help :-) I'll just develop under windows and then upload to the server.
Regards,
Hansheng
I have the same problem on Linux machine, because installed php70-event.
Try commented line in file ext-event.ini
@AlexanderGur !!! Thank you so very much!! Your solution works! I have absolutely zero idea how and why I installed that plugin...
@AlexanderGur
Interesting... @GrahamCampbell , @themsaid , @taylorotwell
Rename class App\Events\Event to App\Events\BaseEvent and change the children Event classes.
It works for me
You can fix it by adding the following to bootstrap/app.php:
$app->withFacades(true, [
'Illuminate\Support\Facades\Event' => 'LumenEvent',
]);
Most helpful comment
I have the same problem on Linux machine, because installed php70-event.
Try commented line in file ext-event.ini