docker-php icon indicating copy to clipboard operation
docker-php copied to clipboard

pecl-event incompatible with Laravel

Open TKr opened this issue 2 years ago • 2 comments

Bug ? Notice ?

pecl-event registers class Event::class laravel has own "Facade" system and register Event as Illuminate\Support\Facades\Event::class but can not, pecl-event has already done this

Laravel's Event::dispatch(something) ends with error.

TKr avatar May 23 '22 14:05 TKr

Hi @TKr, sorry for the issue. Can you help me reproduce? Can you please write which libraries are you installing and their versions? Maybe try attaching your composer.json redacting anything that you don't want to share…?

fquffio avatar May 23 '22 14:05 fquffio

I show this on php7.4 and laravel 6.X (but wersion do not matter in this case)

  1. docker run -it chialab/php:7.4 bash
  2. composer create-project --prefer-dist laravel/laravel test "6.*"
  3. cd test
  4. ./artisan tinker
  5. Event::dispatch() PHP Error: Call to undefined method Event::dispatch() in Psy Shell code on line 1 should return TypeError: Too few arguments to function Illuminate\Events\Dispatcher::dispatch(), 0 passed in ....
  6. class_parents(Event::class) => [] should return => [ "Illuminate\Support\Facades\Facade" => "Illuminate\Support\Facades\Facade", ]

Zrzut ekranu 2022-05-23 o 17 58 31 Instead of returning Laravel Facade Event class comes from extension https://www.php.net/manual/en/class.event.php I know. Facade is "invented" for laravel and good practice is to not use them. But unfortunately there is many projects which use it that way.

Example 2: event package removed from Dockerfile (mine local build):

Zrzut ekranu 2022-05-23 o 17 57 10

Event comes from Laravel as expected

I don know is this a bug, which should be fixed, and event extension removed. I just noticing that some frameworks with event enabled my not working correctly.

TKr avatar May 23 '22 16:05 TKr