Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Laravel Octane Support #2638

Closed
mcolominas opened this issue Jul 11, 2022 · 2 comments
Closed

Add Laravel Octane Support #2638

mcolominas opened this issue Jul 11, 2022 · 2 comments

Comments

@mcolominas
Copy link

Responding to a thread on laravel/octane (laravel/octane#551 (comment)), I discovered a bug in this package.

From what I indicate in the title, this package is not supported when using Laravel Octane.

  • What is the problem?
    When updating the language of the application using app()->setLocale('xx'), the language in carbon is not updated

  • Where does the problem originate?
    In:

    $app = $this->app && method_exists($this->app, 'getLocale') ? $this->app : app('translator');

    Gets the application from when laravel octane is instantiated, so even if the language is changed, it will continue to return the default language, causing carbon to not update.

  • How to solve the problem?
    Change the $this->app inside updateLocale

    public function updateLocale()

    to Illuminate\Container\Container::getInstance()

This solution should work whether laravel octane is used or not.

@kylekatarnls
Copy link
Collaborator

We'll try to work around this issue, but this is a global pitfall for any laravel service provider, it should instead be fixed in https://github.com/laravel/octane/blob/1.x/src/CurrentApplication.php#L25 IMO where Octane could change the app for each provider.

@kylekatarnls
Copy link
Collaborator

I proposed instead a global fix in laravel/octane for any provider doing similar boot process: laravel/octane#556

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants