Frostist's avatar

Errors on server but none on local

On my local build of Laravel 12 running on MacOS with herd, I have everything working perfectly. No errors in the logs, nothing in the browser, my .env file basically matches my .env.server file, except for the fact the server file has a mysql database and the local one uses sqlite.

But... On the server, things just seem to fall apart.

I run:

  • mv .env.server .env
  • composer update
  • npm install
  • npm run build
  • php artisan key:generate

All those good things. But then once I have created an account and logged in, I get my first two browser errors and then the program crashes when I click a Livewire button

<form wire:submit="sendMessage" class="space-y-6">

I get a undefined variable error:

  • Undefined variable $error

Okay, fixed that, then another one, fixed that etc

until I bump heads with:

Class "App\Services\SendService" does not exist

But it does exist! and the whole piece of software works on my laptop, but not on my server...

I have searched and searched, found that you should run composer dump-autoload which I've done and still nothing.

If anyone has any ideas, please help.

Note: I have deleted the entire file directory on my local machine and reinstalled from the same repo as I get from the server, works perfectly on my laptop, just fails on the server.

I have made sure that the server and my laptop have the same php version (8.4.5) same node version (22.14.0) and same npm version (11.3.0).

0 likes
1 reply
Frostist's avatar

As I was writing this I discovered I should also update Composer.

And after doing that I saw these errors on my terminal:

Class App\Livewire\SendMessage located in ./app/Livewire/SendMessage.php does not comply with psr-4 autoloading standard (rule: App\ => ./app). Skipping.

... etc

I then just made sure everything was using 100% the same name, and now it seems to work.

However, when I run composer update on my server I still see those same errors.

Even after running php artisan optimize:clear I still see it and composer dump-autoload

So I am a bit confused as to why it worked 100% on my laptop but not the server.

Both my laptop and server had APP_ENV=local just incase.

If anyone has any idea why, I'd love to understand

Please or to participate in this conversation.