filamentphp / filament

A collection of beautiful full-stack components for Laravel. The perfect starting point for your next app. Using Livewire, Alpine.js and Tailwind CSS.
https://filamentphp.com
MIT License
16.23k stars 2.58k forks source link

configureUsing() method not working on octane #10892

Closed ariaieboy closed 6 months ago

ariaieboy commented 6 months ago

Package

filament/filament

Package Version

v3.2.x

Laravel Version

v10.x

Livewire Version

v3.x

PHP Version

8.3.x

Problem description

from version 3.1.46 the configureUsing method changes are not working on octane.

Expected behavior

configureUsing method changes must apply to all requests.

Steps to reproduce

create a filament app and add a code like this:

        Column::configureUsing(function (Column $col){
            $col->label(fn()=>"id".$col->getName());
        });

The column labels must have id as a prefix in all requests.

Reproduction repository

https://github.com/ariaieboy/filament-octane-bug

Relevant log output

No response

ariaieboy commented 6 months ago

This bug is related to this changes: https://github.com/filamentphp/filament/compare/v3.1.43...v3.1.46

The configureUsing changes only apply to the first request that reaches the octane worker. and in the next requests, the configureUsing method is not applied.

I think the problem here is that Octane only runs the service providers boot and register methods once. And in the next requests it uses the booted laravel.

ariaieboy commented 6 months ago

here is the reproduce repo for this bug: https://github.com/ariaieboy/filament-octane-bug

Note: when you run the application set the worker counts to 1 or you might see the correct answer in some requests since the first request of each worker contains the configureUsing method changes but in the next requests it get cleared.

ariaieboy commented 6 months ago

@danharrin I tested version 3.2.6 but it still has the same problem

sairiz commented 6 months ago

i second that

ariaieboy commented 6 months ago

@danharrin Can you re-open this issue?

ariaieboy commented 6 months ago

I moved every configureUsing method call inside the Filament::serving method and now everything works fine. But I don't know if it is a good approach in terms of performance?

If we could set some globals using the panel configuration that would be awesome.

danharrin commented 6 months ago

I downloaded your repository. Then I installed Roadrunner with Composer. Then I ran octane:start --workers=1.

The column names appear to be correct for me:

https://github.com/filamentphp/filament/assets/41773797/a2f4b202-1e7a-4e1c-84cd-e7380bd3fb02

ariaieboy commented 6 months ago

I downloaded your repository. Then I installed Roadrunner with Composer. Then I ran octane:start --workers=1.

The column names appear to be correct for me:

Screen.Recording.2024-01-20.at.16.01.23.mov

that's because I put the function in the register method of the appServiceProvider but according to the filament docs we are supposed to put the configureUsing method in boot method 🤔

If you move the method into the boot method it won't work with octane.

danharrin commented 6 months ago

Will reopen if more info is provided, but for now I don't know how I can help further.

danharrin commented 6 months ago

ok just seen the comment, reopening.

ariaieboy commented 6 months ago

If we put the configureUsing methods into the register method both octane and non-octane apps will work. I think we should update the docs and add a note about the octane. So people know that if they want to use configureUsing with octane they must put it in the register method, not the boot method.

danharrin commented 6 months ago

Should be fixed by #10947.