laravellaravel-eventslaravel-websockets

Laravel event() not working in production


im trying to deploy my laravel-project via forge and digitalocean. And while it is working perfectly fine in my local development enviroment, im having a hard time getting the laravel-websockets package running.

So while my "CruiseCrontroller" is functioning perfectly locally, somehow in production is giving me following error.

[2020-12-22 15:42:00] production.ERROR: Class 'App\Events\newRoom' not found {"exception":"[object] (Error(code: 0): Class 'App\\Events\newRoom' not found at /home/forge/default/app/Http/Controllers/CruiseController.php:49)

this is the mentioned line in the CruiseController:

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use Illuminate\Support\Facades\Hash;
use App\Events\newRoom;
use App\Events\RoomStatusUpdate;
use App\Room;
use App\Sailor;
use Carbon\Carbon;

class CruiseController extends Controller
{
    public function newRoom(Request $request){
   
    ...
    event(new NewRoom($room->channel_id));
}
...

I googled and searched through stackoverflow for 2h now and hope someone here can point me in the right direction. Thank you


Solution

  • Case is important in case sensitive filesystems. You import the following class:

    use App\Events\newRoom;
    

    while you should import

    use App\Events\NewRoom;
    

    The autoloader tries to find the newRoom.php file and fails to do it because the file with that name doesn't exist.