Home Arrow Icon Knowledge base Arrow Icon Global Arrow Icon Class "appprovidersfortifyserviceprovider" not found


Class "app\providers\fortifyserviceprovider" not found


The error "class "app\providers\fortifyserviceprovider" not found" typically occurs when Laravel is unable to locate the `FortifyServiceProvider` class in your application.

To resolve this issue, follow these steps:

1. Ensure that the `FortifyServiceProvider` class exists:
- Check if you have a file named `FortifyServiceProvider.php` in your `app/Providers` directory.
- Verify that the namespace at the top of the file matches the directory structure: `namespace App\Providers;`.

2. Register the `FortifyServiceProvider` in your application:
- Open your `config/app.php` file.
- In the `providers` array, add the `FortifyServiceProvider`:

php
'providers' => [
    // ...
    App\Providers\FortifyServiceProvider::class,
],

3. Ensure that the `FortifyServiceProvider` is properly implemented:
- Open your `FortifyServiceProvider` class.
- Verify that the class extends `Illuminate\Support\ServiceProvider` and implements the necessary methods, such as `register()` and `boot()`.

php
<?php

namespace App\Providers;

use Laravel\Fortify\Fortify;
use Illuminate\Support\ServiceProvider;

class FortifyServiceProvider extends ServiceProvider
{
    /**
     * Register any application services.
     *
     * @return void
     */
    public function register()
    {
        //
    }

    /**
     * Bootstrap any application services.
     *
     * @return void
     */
    public function boot()
    {
        Fortify::createUsersUsing(CreateNewUser::class);
        // ...
    }
}

4. Clear the application cache:
- Run the command `php artisan config:clear` to clear the cached configuration files.
- Run the command `php artisan cache:clear` to clear the application cache.

After following these steps, the error "class "app\providers\fortifyserviceprovider" not found" should be resolved. If the issue persists, ensure that your `FortifyServiceProvider` class is correctly named, located in the right directory, and properly registered in your application's service provider list.