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

JannatNatasha's avatar

Laravel export is not working

I'm working on the Excel exports in my laravel project. Now I get this error:Class 'App\Export\UsersExport' not found I made 3 others and they worked. This one doesn't and I can't seem to figure out what causes this error. I'm using "Maatwebsite's Laravel-Excel".

My exports controller:

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

//exports
use App\Export\UsersExport;
use App\Exports\StudyClassExport;
use App\Exports\EducationsExport;
use App\Exports\IntakesExport;
use Maatwebsite\Excel\Facades\Excel;
use App\Http\Controllers\Controller;

class ExportsController extends Controller
{
    public function users()
    {
        return Excel::download(new UsersExport, 'gebruikers.xlsx');
    }

    public function educations()
    {
        return Excel::download(new EducationsExport, 'opleidingen.xlsx');
    }

    public function classes()
    {
        return Excel::download(new StudyClassExport, 'klassen.xlsx');
    }

    public function intakes()
    {
        return Excel::download(new IntakesExport, 'intakes.xlsx');
    }
}

UsersExport:

<?php

namespace App\Exports;

use App\User;
use Maatwebsite\Excel\Concerns\FromCollection;

class UsersExport implements FromCollection
{
    /**
    * @return \Illuminate\Support\Collection
    */
    public function collection()
    {
        return User::all();
    }
}

I have no idea what causes this error. The others work but this one doesn't

0 likes
3 replies
tisuchi's avatar
tisuchi
Best Answer
Level 70

@jannatnatasha

You have a typo:

use App\Export\UsersExport;
use App\Exports\UsersExport;
10 likes

Please or to participate in this conversation.