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

mbo's avatar
Level 3

Middleware error

Hello,

i have an questions about an error i get. The situation is as follows:

  • in my local development setup my website works fine.

I have set the website up on a shared hosting account. I did this by following this tutorial: https://dev.to/asapabedi/deploying-laravel-5-applications-on-shared-hosting-without-the-use-of-ssh--16a6

This resulted in the following:

  • Frontend works fine
  • When trying to login i get the following error: Class App\Http\Middleware\CheckRole does not exist

Any idea how to solve this?

Help would be very appreciated.

thanks in advance.

0 likes
10 replies
jlrdw's avatar

If this actually works in local but not production, you are either missing some files, missing a permission, or your case is off. Linux is cAsE SenSitive.

mbo's avatar
Level 3

indeed: case sensitive caused the error! thanks! (im new in this.. :-) )

mbo's avatar
Level 3

JlRDW,

thanks for the reply. Additional on the former error i get a other error (in local production it works).

Call to undefined function autoVer() (View: xxxx

in the view i have this code:

<link rel="stylesheet" type="text/css" href="<?php echo e(autoVer("css/styles.css")); ?>">

this should trigger a helper file. In this helper file there is function:

function autoVer($url){
    $path = pathinfo($url);
    $ver = filemtime($_SERVER['DOCUMENT_ROOT'].$url);
    echo '/../'.$path['dirname'].'/'.$path['basename'].'?v='.$ver;
}

Any idea why the function is not reached?

Hope you can help me with this.

br

maarten

Sinnbeck's avatar

I suggest creating a new topic as this does not seem related to the first issue.

My best guess would be that the helper file isn't loaded in composer.json. I assume that is how you load it?

Sinnbeck's avatar

I would need to know how you are loading your helpers file:)

The reason I suggested it is that this thread is marked solved, and therefor most people won't open it op help out

mbo's avatar
Level 3

I have to think how i have done it (have set this a long time ago).

this is how i load all files in the helpers directory.


namespace App\Providers;

use Illuminate\Support\ServiceProvider;

class HelperServiceProvider extends ServiceProvider
{
    /**
     * Bootstrap the application services.
     *
     * @return void
     */
    public function boot()
    {
        //
    }

    /**
     * Register the application services.
     *
     * @return void
     */
    public function register()
    {
          foreach (glob(app_path().'/Helpers/*.php') as $filename){
           require_once($filename);
          }
    }
}

The question is if this is doing the job.

Is there a way to check if the fill is loaded?

Sinnbeck's avatar
Sinnbeck
Best Answer
Level 102

That should work but maybe some restriction on the shared host. Try checking the logs

mbo's avatar
Level 3

thanks, i will check the hosting provider

Please or to participate in this conversation.