Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

shami003's avatar

I am getting internal server error after uploading to shared hosting

I am getting 500 internal server error after deploying my app to hosting server. Only the main page is working and other pages gives this error. I think there is some issue with AppServiceProvider boot method because I am fetching categories in every page and for home page I fetched it with products.

Here is AppServiceProvider boot method

public function boot()
    {
        $categories = Category::take(10)->latest()->get();
        View::share('categories', $categories);
    }

Some latest logs I have

#18 /home/sham/auction/app/Providers/AppServiceProvider.php(28): Illuminate\Database\Eloquent\Builder->get()
#19 [internal function]: App\Providers\AppServiceProvider->boot()
#20 /home/sham/auction/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(32): call_user_func_array(Array, Array)
#21 /home/sham/auction/vendor/laravel/framework/src/Illuminate/Container/Util.php(36): Illuminate\Container\BoundMethod::Illuminate\Container\{closure}()
#22 /home/sham/auction/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(90): Illuminate\Container\Util::unwrapIfClosure(Object(Closure))
#23 /home/sham/auction/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(34): Illuminate\Container\BoundMethod::callBoundMethod(Object(Illuminate\Foundation\Application), Array, Object(Closure))
#24 /home/sham/auction/vendor/laravel/framework/src/Illuminate/Container/Container.php(590): Illuminate\Container\BoundMethod::call(Object(Illuminate\Foundation\Application), Array, Array, NULL)
#25 /home/sham/auction/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(856): Illuminate\Container\Container->call(Array)
#26 /home/sham/auction/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(839): Illuminate\Foundation\Application->bootProvider(Object(App\Providers\AppServiceProvider))
#27 [internal function]: Illuminate\Foundation\Application->Illuminate\Foundation\{closure}(Object(App\Providers\AppServiceProvider), 20)
#28 /home/sham/auction/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(840): array_walk(Array, Object(Closure))
#29 /home/sham/auction/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/BootProviders.php(17): Illuminate\Foundation\Application->boot()
#30 /home/sham/auction/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(219): Illuminate\Foundation\Bootstrap\BootProviders->bootstrap(Object(Illuminate\Foundation\Application))
#31 /home/sham/auction/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(156): Illuminate\Foundation\Application->bootstrapWith(Array)
#32 /home/sham/auction/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(140): Illuminate\Foundation\Http\Kernel->bootstrap()
#33 /home/sham/auction/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(110): Illuminate\Foundation\Http\Kernel->sendRequestThroughRouter(Object(Illuminate\Http\Request))
#34 /home/sham/public_html/index.php(55): Illuminate\Foundation\Http\Kernel->handle(Object(Illuminate\Http\Request))
#35 {main}
0 likes
13 replies
Wakanda's avatar

@shami003 can you set your app local in your .env to get more info from the debugger, currently, your service provider looks fine

Tangente's avatar

Check your log file, it should list what went wrong.

shami003's avatar

I have updated my question with logs, it may help

golapraj's avatar

make debug true on .env and you will get details about error.

APP_DEBUG=true
Snapey's avatar

show the error from the log file

pasting the stack from line 18 onwards is no use we need the stuff that comes before line 1 of the stack trace

shami003's avatar

Thank you so much all of you. The issue is solved. I have changed the code in boot method. I am pasting the working code for future reference.

public function boot()
    {
        view()->composer('*', function ($view) {
            $view->with('categories', Category::take(10)->latest()->get());
        });
    }
Snapey's avatar

beware binding to *

This database query will run for every view. this includes all included files, so if your page extends layout, which includes header and footer as separate files then you just ran the query 4 times

Ive not tested it but my suspicion is that it will run for components also.

Using * is never really a good idea

shami003's avatar

@snapey what will be the downside of using *,

What can I use instead of this, I have used the other way before but it didn't worked

Snapey's avatar

As mentioned. the downside is that you run the query for every view that makes up the response.

I would only mention the view file that you actually show this data

Please or to participate in this conversation.