chialab / docker-php

🧰 Adding common PHP extensions to some of the official PHP Docker images.
MIT License
437 stars 112 forks source link

pecl-event incompatible with Laravel #103

Open TKr opened 2 years ago

TKr commented 2 years ago

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.

fquffio commented 2 years ago

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…?

TKr commented 2 years ago

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.