我正在尝试将干预图像集成到我的项目中。我已经按照指南,使用了其他教程的shitton,无论我做什么,我都会遇到同样的错误:
Class 'Intervention\Image\ImageServiceProvider' not found
它包含在我的composer.json
:
{
"require": {
"laravel/envoy": "~1.0",
"laravel/installer": "^1.3",
"intervention/image": "^2.3"
}
}
我已经安装了php-gd,我包括
Intervention\Image\ImageServiceProvider::class
和
'Image' => Intervention\Image\Facades\Image::class
在我的config\app.php
中,但我一直收到恼人的错误消息。
也许值得一提的是我使用的是Linux Mint操作系统,并且我正在使用Homestead虚拟机。是的,我在Homestead版本的Composer中包含了这些东西,而不是我的主要PC作曲家。使用时
PHP artisan --version
,它返回:
Laravel Framework version 5.2.43
我在虚拟机上运行了作曲家更新,没有解决问题。我尝试从app.php
删除行,运行composer update,再次添加行并运行composer update,但是没有用。
config\app.php
中包含哪些内容是否重要?现在,别名位于列表中,提供程序位于Package Service Providers下。
以下是完整的错误消息:
Whoops, looks like something went wrong.
1/1
FatalThrowableError in ProviderRepository.php line 146:
Class 'Intervention\Image\ImageServiceProvider' not found
in ProviderRepository.php line 146
at ProviderRepository->createProvider('Intervention\Image\ImageServiceProvider') in ProviderRepository.php line 114
at ProviderRepository->compileManifest(array('Illuminate\Auth\AuthServiceProvider', 'Illuminate\Broadcasting\BroadcastServiceProvider', 'Illuminate\Bus\BusServiceProvider', 'Illuminate\Cache\CacheServiceProvider', 'Illuminate\Foundation\Providers\ConsoleSupportServiceProvider', 'Illuminate\Cookie\CookieServiceProvider', 'Illuminate\Database\DatabaseServiceProvider', 'Illuminate\Encryption\EncryptionServiceProvider', 'Illuminate\Filesystem\FilesystemServiceProvider', 'Illuminate\Foundation\Providers\FoundationServiceProvider', 'Illuminate\Hashing\HashServiceProvider', 'Illuminate\Mail\MailServiceProvider', 'Illuminate\Pagination\PaginationServiceProvider', 'Illuminate\Pipeline\PipelineServiceProvider', 'Illuminate\Queue\QueueServiceProvider', 'Illuminate\Redis\RedisServiceProvider', 'Illuminate\Auth\Passwords\PasswordResetServiceProvider', 'Illuminate\Session\SessionServiceProvider', 'Illuminate\Translation\TranslationServiceProvider', 'Illuminate\Validation\ValidationServiceProvider', 'Illuminate\View\ViewServiceProvider', 'Intervention\Image\ImageServiceProvider', 'App\Providers\AppServiceProvider', 'App\Providers\AuthServiceProvider', 'App\Providers\EventServiceProvider', 'App\Providers\RouteServiceProvider')) in ProviderRepository.php line 60
at ProviderRepository->load(array('Illuminate\Auth\AuthServiceProvider', 'Illuminate\Broadcasting\BroadcastServiceProvider', 'Illuminate\Bus\BusServiceProvider', 'Illuminate\Cache\CacheServiceProvider', 'Illuminate\Foundation\Providers\ConsoleSupportServiceProvider', 'Illuminate\Cookie\CookieServiceProvider', 'Illuminate\Database\DatabaseServiceProvider', 'Illuminate\Encryption\EncryptionServiceProvider', 'Illuminate\Filesystem\FilesystemServiceProvider', 'Illuminate\Foundation\Providers\FoundationServiceProvider', 'Illuminate\Hashing\HashServiceProvider', 'Illuminate\Mail\MailServiceProvider', 'Illuminate\Pagination\PaginationServiceProvider', 'Illuminate\Pipeline\PipelineServiceProvider', 'Illuminate\Queue\QueueServiceProvider', 'Illuminate\Redis\RedisServiceProvider', 'Illuminate\Auth\Passwords\PasswordResetServiceProvider', 'Illuminate\Session\SessionServiceProvider', 'Illuminate\Translation\TranslationServiceProvider', 'Illuminate\Validation\ValidationServiceProvider', 'Illuminate\View\ViewServiceProvider', 'Intervention\Image\ImageServiceProvider', 'App\Providers\AppServiceProvider', 'App\Providers\AuthServiceProvider', 'App\Providers\EventServiceProvider', 'App\Providers\RouteServiceProvider')) in Application.php line 530
at Application->registerConfiguredProviders() in RegisterProviders.php line 17
at RegisterProviders->bootstrap(object(Application)) in Application.php line 203
at Application->bootstrapWith(array('Illuminate\Foundation\Bootstrap\DetectEnvironment', 'Illuminate\Foundation\Bootstrap\LoadConfiguration', 'Illuminate\Foundation\Bootstrap\ConfigureLogging', 'Illuminate\Foundation\Bootstrap\HandleExceptions', 'Illuminate\Foundation\Bootstrap\RegisterFacades', 'Illuminate\Foundation\Bootstrap\RegisterProviders', 'Illuminate\Foundation\Bootstrap\BootProviders')) in Kernel.php line 232
at Kernel->bootstrap() in Kernel.php line 127
at Kernel->sendRequestThroughRouter(object(Request)) in Kernel.php line 99
at Kernel->handle(object(Request)) in index.php line 53
答案 0 :(得分:2)
我遇到了同样的问题,事实证明我没有在项目的根目录上运行此命令$ php composer.phar require intervention/image
。我确实在我的项目的根目录上运行它,一切都很好。
E.g
Itses-MacBook-Pro:testproject bigtank$ composer require intervention/image
像这样运行它会起作用。
干杯。
答案 1 :(得分:0)
从config/app.php
移除外观和服务提供商,然后运行composer dumpauto
(如果无效,请运行composer dumpauto -o
)。之后,将Facade和服务提供商添加回config/app.php
。
答案 2 :(得分:0)
请确保您认真遵循了安装指南。
您需要先运行:
composer require intervention/image
,并且您应该在已经安装此软件包后修改config.app.php(因此
运行composer require
),而不是之前。