furey / tinx

⛔️ Laravel Tinx is archived and no longer maintained.
449 stars 37 forks source link

re() doesn't reload observers code #50

Closed anderson-xd closed 4 years ago

anderson-xd commented 6 years ago

Hello,

First of all, I'm loving tinx!

But now comes the problem, I'm developing an observer and I'm testing it on tinx, it happens that when I change something in observer and I use the re();

My change does not happen in tinx, I need to give an exit and run it all over again to make it work :(

Is there any limitation for observers?

Thank you.

ajthinking commented 6 years ago

Are you on version 2.1.6? Where is your observer class located and is it autoloaded? I have noted the following in my current application:

    public static function sayHi()
    {
        return "change_number_123";
    }
anderson-xd commented 6 years ago

Yes, I'm in version 2.1.6. I tested what you asked for and it worked with re();

My observer is in App/Observers it is called by ObserverProvider, this provider is in the default App/Providers folder and it is registered in config/app.php along with the other providers.

furey commented 5 years ago

Hi @anderson-flores,

I've just spent a bit of time looking into this.

It seems like classes used in service providers don't reload changes properly on re().

I'm guessing this has something to do with class autoloading and where these classes are first defined in an application's running order relative to Tinx's reload functionality… but I'm not sure.

For example, if your ObserverProvider has use statements referencing your model and observer classes, they probably won't reload class changes on re(). But if you pulled those classes out of that provider and instead called App\[Model]::observe(App\Observers\[Model]Observer::class) from somewhere else in your application (outside of the server provider stack), your changes will probably reload correctly on re().

I'm not sure how to fix the issue, but am documenting my findings here in case it prompts any ideas or suggestions from any other users.

Cheers.

TsaiKoga commented 5 years ago

I have this problem with my php@7.1. After I updated php version to 7.2, re() is working now

furey commented 4 years ago

⛔️ Closing open issues and pull requests as the project is now archived.