Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does isLocal() actually do in Laravel?

Tags:

laravel

I've been looking into Laravel Telescope and it mentioned the ability of being able to run only in one's local environment as opposed to production by including the following code snippet in AppServiceProvider.

public function register()
{
    if ($this->app->isLocal()) {
        $this->app->register(TelescopeServiceProvider::class);
    }
}

This works fine but I am trying to figure out what exactly the isLocal() method does. So far, I have not been able to find much information.

Thanks,

like image 847
Evan Lalo Avatar asked Sep 16 '25 10:09

Evan Lalo


1 Answers

In your .env file you would have a APP_ENV set to local on your development environment and it will be different on other servers. So isLocal just checks if that is set to local or not.

Here is the answer from the repository.

To check for a different env other than local or production use this helper function:

config('app.env') // get the env

for production there is a isProduction() helper function on the app instance.

like image 52
nakov Avatar answered Sep 18 '25 05:09

nakov