This is the error message that shows up in my browser:
Class ‘AppProvidersFortifyServiceProvider’not found in C:xampphtdocsblogvendorlaravelframeworksrcIlluminateFoundationProviderRepository.php (line 209)
public function createProvider($provider) //line 207
{ //line 208
return new $provider($this->app); //line 209
} //line 210
Code in ProviderRepository.php:
<?php
namespace IlluminateFoundation;
use Exception;
use IlluminateContractsFoundationApplication as ApplicationContract;
use IlluminateFilesystemFilesystem;
class ProviderRepository
{
/**
* The application implementation.
*
* @var IlluminateContractsFoundationApplication
*/
protected $app;
/**
* The filesystem instance.
*
* @var IlluminateFilesystemFilesystem
*/
protected $files;
/**
* The path to the manifest file.
*
* @var string
*/
protected $manifestPath;
/**
* Create a new service repository instance.
*
* @param IlluminateContractsFoundationApplication $app
* @param IlluminateFilesystemFilesystem $files
* @param string $manifestPath
* @return void
*/
public function __construct(ApplicationContract $app, Filesystem $files, $manifestPath)
{
$this->app = $app;
$this->files = $files;
$this->manifestPath = $manifestPath;
}
/**
* Register the application service providers.
*
* @param array $providers
* @return void
*/
public function load(array $providers)
{
$manifest = $this->loadManifest();
// First we will load the service manifest, which contains information on all
// service providers registered with the application and which services it
// provides. This is used to know which services are "deferred" loaders.
if ($this->shouldRecompile($manifest, $providers)) {
$manifest = $this->compileManifest($providers);
}
// Next, we will register events to load the providers for each of the events
// that it has requested. This allows the service provider to defer itself
// while still getting automatically loaded when a certain event occurs.
foreach ($manifest['when'] as $provider => $events) {
$this->registerLoadEvents($provider, $events);
}
// We will go ahead and register all of the eagerly loaded providers with the
// application so their services can be registered with the application as
// a provided service. Then we will set the deferred service list on it.
foreach ($manifest['eager'] as $provider) {
$this->app->register($provider);
}
$this->app->addDeferredServices($manifest['deferred']);
}
/**
* Load the service provider manifest JSON file.
*
* @return array|null
*/
public function loadManifest()
{
// The service manifest is a file containing a JSON representation of every
// service provided by the application and whether its provider is using
// deferred loading or should be eagerly loaded on each request to us.
if ($this->files->exists($this->manifestPath)) {
$manifest = $this->files->getRequire($this->manifestPath);
if ($manifest) {
return array_merge(['when' => []], $manifest);
}
}
}
/**
* Determine if the manifest should be compiled.
*
* @param array $manifest
* @param array $providers
* @return bool
*/
public function shouldRecompile($manifest, $providers)
{
return is_null($manifest) || $manifest['providers'] != $providers;
}
/**
* Register the load events for the given provider.
*
* @param string $provider
* @param array $events
* @return void
*/
protected function registerLoadEvents($provider, array $events)
{
if (count($events) < 1) {
return;
}
$this->app->make('events')->listen($events, function () use ($provider) {
$this->app->register($provider);
});
}
/**
* Compile the application service manifest file.
*
* @param array $providers
* @return array
*/
protected function compileManifest($providers)
{
// The service manifest should contain a list of all of the providers for
// the application so we can compare it on each request to the service
// and determine if the manifest should be recompiled or is current.
$manifest = $this->freshManifest($providers);
foreach ($providers as $provider) {
$instance = $this->createProvider($provider);
// When recompiling the service manifest, we will spin through each of the
// providers and check if it's a deferred provider or not. If so we'll
// add it's provided services to the manifest and note the provider.
if ($instance->isDeferred()) {
foreach ($instance->provides() as $service) {
$manifest['deferred'][$service] = $provider;
}
$manifest['when'][$provider] = $instance->when();
}
// If the service providers are not deferred, we will simply add it to an
// array of eagerly loaded providers that will get registered on every
// request to this application instead of "lazy" loading every time.
else {
$manifest['eager'][] = $provider;
}
}
return $this->writeManifest($manifest);
}
/**
* Create a fresh service manifest data structure.
*
* @param array $providers
* @return array
*/
protected function freshManifest(array $providers)
{
return ['providers' => $providers, 'eager' => [], 'deferred' => []];
}
/**
* Write the service manifest file to disk.
*
* @param array $manifest
* @return array
*
* @throws Exception
*/
public function writeManifest($manifest)
{
if (! is_writable($dirname = dirname($this->manifestPath))) {
throw new Exception("The {$dirname} directory must be present and writable.");
}
$this->files->replace(
$this->manifestPath, '<?php return '.var_export($manifest, true).';'
);
return array_merge(['when' => []], $manifest);
}
/**
* Create a new provider instance.
*
* @param string $provider
* @return IlluminateSupportServiceProvider
*/
public function createProvider($provider)
{
return new $provider($this->app);
}
}
I had looked through my config/app.php to see whether did I include this service provider but everything seems just fine to me.
Code for config/app.php:
<?php
// namespace AppProviders;
return [
/*
|--------------------------------------------------------------------------
| Application Name
|--------------------------------------------------------------------------
|
| This value is the name of your application. This value is used when the
| framework needs to place the application's name in a notification or
| any other location as required by the application or its packages.
*/
'name' => env('APP_NAME', 'Laravel'),
/*
|--------------------------------------------------------------------------
| Application Environment
|--------------------------------------------------------------------------
|
| This value determines the "environment" your application is currently
| running in. This may determine how you prefer to configure various
| services your application utilizes. Set this in your ".env" file.
|
*/
'env' => env('APP_ENV', 'production'),
/*
|--------------------------------------------------------------------------
| Application Debug Mode
|--------------------------------------------------------------------------
|
| When your application is in debug mode, detailed error messages with
| stack traces will be shown on every error that occurs within your
| application. If disabled, a simple generic error page is shown.
|
*/
'debug' => env('APP_DEBUG', false),
/*
|--------------------------------------------------------------------------
| Application URL
|--------------------------------------------------------------------------
|
| This URL is used by the console to properly generate URLs when using
| the Artisan command line tool. You should set this to the root of
| your application so that it is used when running Artisan tasks.
|
*/
'url' => env('APP_URL', 'http://localhost'),
/*
|--------------------------------------------------------------------------
| Application Timezone
|--------------------------------------------------------------------------
|
| Here you may specify the default timezone for your application, which
| will be used by the PHP date and date-time functions. We have gone
| ahead and set this to a sensible default for you out of the box.
|
*/
'timezone' => 'UTC',
/*
|--------------------------------------------------------------------------
| Application Locale Configuration
|--------------------------------------------------------------------------
|
| The application locale determines the default locale that will be used
| by the translation service provider. You are free to set this value
| to any of the locales which will be supported by the application.
|
*/
'locale' => 'en',
/*
|--------------------------------------------------------------------------
| Application Fallback Locale
|--------------------------------------------------------------------------
|
| The fallback locale determines the locale to use when the current one
| is not available. You may change the value to correspond to any of
| the language folders that are provided through your application.
|
*/
'fallback_locale' => 'en',
/*
|--------------------------------------------------------------------------
| Encryption Key
|--------------------------------------------------------------------------
|
| This key is used by the Illuminate encrypter service and should be set
| to a random, 32 character string, otherwise these encrypted strings
| will not be safe. Please do this before deploying an application!
|
*/
'key' => env('APP_KEY'),
'cipher' => 'AES-256-CBC',
/*
|--------------------------------------------------------------------------
| Logging Configuration
|--------------------------------------------------------------------------
|
| Here you may configure the log settings for your application. Out of
| the box, Laravel uses the Monolog PHP logging library. This gives
| you a variety of powerful log handlers / formatters to utilize.
|
| Available Settings: "single", "daily", "syslog", "errorlog"
|
*/
'log' => env('APP_LOG', 'single'),
'log_level' => env('APP_LOG_LEVEL', 'debug'),
/*
|--------------------------------------------------------------------------
| Autoloaded Service Providers
|--------------------------------------------------------------------------
|
| The service providers listed here will be automatically loaded on the
| request to your application. Feel free to add your own services to
| this array to grant expanded functionality to your applications.
|
*/
'providers' => [
/*
* Laravel Framework Service Providers...
*/
IlluminateAuthAuthServiceProvider::class,
IlluminateBroadcastingBroadcastServiceProvider::class,
IlluminateBusBusServiceProvider::class,
IlluminateCacheCacheServiceProvider::class,
IlluminateFoundationProvidersConsoleSupportServiceProvider::class,
IlluminateCookieCookieServiceProvider::class,
IlluminateDatabaseDatabaseServiceProvider::class,
IlluminateEncryptionEncryptionServiceProvider::class,
IlluminateFilesystemFilesystemServiceProvider::class,
IlluminateFoundationProvidersFoundationServiceProvider::class,
IlluminateHashingHashServiceProvider::class,
IlluminateMailMailServiceProvider::class,
IlluminateNotificationsNotificationServiceProvider::class,
IlluminatePaginationPaginationServiceProvider::class,
IlluminatePipelinePipelineServiceProvider::class,
IlluminateQueueQueueServiceProvider::class,
IlluminateRedisRedisServiceProvider::class,
IlluminateAuthPasswordsPasswordResetServiceProvider::class,
IlluminateSessionSessionServiceProvider::class,
IlluminateTranslationTranslationServiceProvider::class,
IlluminateValidationValidationServiceProvider::class,
IlluminateViewViewServiceProvider::class,
/*
* Package Service Providers...
*/
LaravelTinkerTinkerServiceProvider::class,
/*
* Application Service Providers...
*/
AppProvidersAppServiceProvider::class,
AppProvidersAuthServiceProvider::class,
// AppProvidersBroadcastServiceProvider::class,
AppProvidersEventServiceProvider::class,
AppProvidersRouteServiceProvider::class,
AppProvidersFortifyServiceProvider::class,
AppProvidersJetstreamServiceProvider::class,
],
/*
|--------------------------------------------------------------------------
| Class Aliases
|--------------------------------------------------------------------------
|
| This array of class aliases will be registered when this application
| is started. However, feel free to register as many as you wish as
| the aliases are "lazy" loaded so they don't hinder performance.
|
*/
'aliases' => [
'App' => IlluminateSupportFacadesApp::class,
'Artisan' => IlluminateSupportFacadesArtisan::class,
'Auth' => IlluminateSupportFacadesAuth::class,
'Blade' => IlluminateSupportFacadesBlade::class,
'Broadcast' => IlluminateSupportFacadesBroadcast::class,
'Bus' => IlluminateSupportFacadesBus::class,
'Cache' => IlluminateSupportFacadesCache::class,
'Config' => IlluminateSupportFacadesConfig::class,
'Cookie' => IlluminateSupportFacadesCookie::class,
'Crypt' => IlluminateSupportFacadesCrypt::class,
'DB' => IlluminateSupportFacadesDB::class,
'Eloquent' => IlluminateDatabaseEloquentModel::class,
'Event' => IlluminateSupportFacadesEvent::class,
'File' => IlluminateSupportFacadesFile::class,
'Gate' => IlluminateSupportFacadesGate::class,
'Hash' => IlluminateSupportFacadesHash::class,
'Lang' => IlluminateSupportFacadesLang::class,
'Log' => IlluminateSupportFacadesLog::class,
'Mail' => IlluminateSupportFacadesMail::class,
'Notification' => IlluminateSupportFacadesNotification::class,
'Password' => IlluminateSupportFacadesPassword::class,
'Queue' => IlluminateSupportFacadesQueue::class,
'Redirect' => IlluminateSupportFacadesRedirect::class,
'Redis' => IlluminateSupportFacadesRedis::class,
'Request' => IlluminateSupportFacadesRequest::class,
'Response' => IlluminateSupportFacadesResponse::class,
'Route' => IlluminateSupportFacadesRoute::class,
'Schema' => IlluminateSupportFacadesSchema::class,
'Session' => IlluminateSupportFacadesSession::class,
'Storage' => IlluminateSupportFacadesStorage::class,
'URL' => IlluminateSupportFacadesURL::class,
'Validator' => IlluminateSupportFacadesValidator::class,
'View' => IlluminateSupportFacadesView::class,
],
];
I also tried some of the other solutions that I found on Google like using commands like composer dump-autoload
, php artisan config:cache
, and so on. In fact, none of them work, every time I tried to run any commands in my command prompt it will show up the same error message ‘Class ‘AppProvidersFortifyServiceProvider’ not found ‘. Does anyone have the idea of how to fix this error? Thanks in advance
3
Answers
May be you forgot
php artisan vendor:publish --provider="LaravelFortifyFortifyServiceProvider"
https://github.com/laravel/fortify
Try
The documentation is a bit misleading because how the service provider code snippet:
"The
vendor:publish
command discussed above will also publish theAppProvidersFortifyServiceProvider
class. You should ensure this class is registered within the providers array of your application’s config/app.php configuration file."If you copy and pasted straight out of the docs
AppProvidersFortifyServiceProvider
into your provider it will break because it needs to be:AppProvidersFortifyServiceProvider::class