ここからの指示に従ってIntervention Image Classをインストールしました。 http://image.intervention.io/getting_started/installation
また、次の2行をconfig/app.phpファイルに追加しました。
'Intervention\Image\ImageServiceProvider'
「画像」=>「介入\画像\ファケード\画像」
Webサイトを開くと、次のエラーが表示されます。
Class 'Intervention\Image\ImageServiceProvider' not found
それはなぜですか、私は今何をすべきですか?
"intervention/image": "dev-master"
ファイルの「require」セクションにcomposer.json
を追加します。
"require": {
"laravel/framework": "4.1.*",
"intervention/image": "dev-master"
},
Run CMD;
$ composer install
この警告がある場合:
警告:ロックファイルはcomposer.jsonの最新の変更に合わせて最新のものではありません。古い依存関係が発生している可能性があります。更新を実行して更新します。
$ composer update
を実行してから$ composer install
を実行します
config/app.php
ファイルを開きます。これを$providers
配列に追加します。
Intervention\Image\ImageServiceProvider::class
次に、これを$aliases
配列に追加します。
'Image' => Intervention\Image\Facades\Image::class
エラーがある場合;
クラス 'Intervention\Image\ImageServiceProvider'が見つかりません
試してみる
$ composer update
これを試して、それは私のために動作します。
use Intervention\Image\Facades\Image as Image;
composer require intervention/image
問題を確実に解決します。
"name": "laravel/laravel",
"description": "The Laravel Framework.",
"keywords": ["framework", "laravel"],
"license": "MIT",
"require": {
"laravel/framework": "4.2.*",
"intervention/image": "dev-master"
},
composer.jsonに新しいコード"intervention/image": "dev-master"を追加し、cmd
$ composer update
追加\
Image
の前のシンボル:
\Image::make();
Laravel 5.3とIntervention 2.3で助けてくれました
コントローラーに書いてください
画像を使用;
config/app.phpプロバイダー
Intervention\Image\ImageServiceProvider :: class、
エイリアス
'Image' => Intervention\Image\Facades\Image :: class、
laravel 5.8では、そのエラーを簡単に修正できます。
最初にconfigフォルダのapp.phpファイルを開き、プロバイダーを追加します
Intervention\Image\ImageServiceProvider::class,
次に、エイリアスに移動して、
'Image' => Intervention\Image\Facades\Image::class
アップロードコントローラーを画像化する場合は、
use Image;
プロバイダー
'providers' => [
/*
* Laravel Framework Service Providers...
*/
Illuminate\Auth\AuthServiceProvider::class,
Illuminate\Broadcasting\BroadcastServiceProvider::class,
Illuminate\Bus\BusServiceProvider::class,
Illuminate\Cache\CacheServiceProvider::class,
Illuminate\Foundation\Providers\ConsoleSupportServiceProvider::class,
Illuminate\Cookie\CookieServiceProvider::class,
Illuminate\Database\DatabaseServiceProvider::class,
Illuminate\Encryption\EncryptionServiceProvider::class,
Illuminate\Filesystem\FilesystemServiceProvider::class,
Illuminate\Foundation\Providers\FoundationServiceProvider::class,
Illuminate\Hashing\HashServiceProvider::class,
Illuminate\Mail\MailServiceProvider::class,
Illuminate\Notifications\NotificationServiceProvider::class,
Illuminate\Pagination\PaginationServiceProvider::class,
Illuminate\Pipeline\PipelineServiceProvider::class,
Illuminate\Queue\QueueServiceProvider::class,
Illuminate\Redis\RedisServiceProvider::class,
Illuminate\Auth\Passwords\PasswordResetServiceProvider::class,
Illuminate\Session\SessionServiceProvider::class,
Illuminate\Translation\TranslationServiceProvider::class,
Illuminate\Validation\ValidationServiceProvider::class,
Illuminate\View\ViewServiceProvider::class,
Intervention\Image\ImageServiceProvider::class,
/*
* Package Service Providers...
*/
/*
* Application Service Providers...
*/
App\Providers\AppServiceProvider::class,
App\Providers\AuthServiceProvider::class,
// App\Providers\BroadcastServiceProvider::class,
App\Providers\EventServiceProvider::class,
App\Providers\RouteServiceProvider::class,
],
エイリアス
'aliases' => [
'App' => Illuminate\Support\Facades\App::class,
'Arr' => Illuminate\Support\Arr::class,
'Artisan' => Illuminate\Support\Facades\Artisan::class,
'Auth' => Illuminate\Support\Facades\Auth::class,
'Blade' => Illuminate\Support\Facades\Blade::class,
'Broadcast' => Illuminate\Support\Facades\Broadcast::class,
'Bus' => Illuminate\Support\Facades\Bus::class,
'Cache' => Illuminate\Support\Facades\Cache::class,
'Config' => Illuminate\Support\Facades\Config::class,
'Cookie' => Illuminate\Support\Facades\Cookie::class,
'Crypt' => Illuminate\Support\Facades\Crypt::class,
'DB' => Illuminate\Support\Facades\DB::class,
'Eloquent' => Illuminate\Database\Eloquent\Model::class,
'Event' => Illuminate\Support\Facades\Event::class,
'File' => Illuminate\Support\Facades\File::class,
'Gate' => Illuminate\Support\Facades\Gate::class,
'Hash' => Illuminate\Support\Facades\Hash::class,
'Lang' => Illuminate\Support\Facades\Lang::class,
'Log' => Illuminate\Support\Facades\Log::class,
'Mail' => Illuminate\Support\Facades\Mail::class,
'Notification' => Illuminate\Support\Facades\Notification::class,
'Password' => Illuminate\Support\Facades\Password::class,
'Queue' => Illuminate\Support\Facades\Queue::class,
'Redirect' => Illuminate\Support\Facades\Redirect::class,
'Redis' => Illuminate\Support\Facades\Redis::class,
'Request' => Illuminate\Support\Facades\Request::class,
'Response' => Illuminate\Support\Facades\Response::class,
'Route' => Illuminate\Support\Facades\Route::class,
'Schema' => Illuminate\Support\Facades\Schema::class,
'Session' => Illuminate\Support\Facades\Session::class,
'Storage' => Illuminate\Support\Facades\Storage::class,
'Str' => Illuminate\Support\Str::class,
'URL' => Illuminate\Support\Facades\URL::class,
'Validator' => Illuminate\Support\Facades\Validator::class,
'View' => Illuminate\Support\Facades\View::class,
'Image' => Intervention\Image\Facades\Image::class
],
コントローラー
<?php
namespace App\Http\Controllers;
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Illuminate\Validation\Rule;
use DB;
use App\User;
use Auth;
use Image;
class ImageController extends Controller{
//code
}