- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
我正在尝试安装干预。我运行这个命令 Composer 需要干预/图片
并且 composer.json 已更新。我在 $aliases 数组中添加 'Image' => 'Intervention\Image\Facades\Image::class' 就可以了。然后我在 $providers 数组中添加
Intervention\Image\ImageServiceProvider::class` 但它没有用。
这是我在输入 composer update 时得到的
PHP Fatal error: Class 'Intervention\Image\ImageServiceProvider' not found in /home/vagrant/Code/laravel-basics/vendor/laravel/framework/src/Illuminate/Foundation/ProviderRepository.php on line 146
[Symfony\Component\Debug\Exception\FatalErrorException]
Class 'Intervention\Image\ImageServiceProvider' not found `
<?php
ProviderRepository.php
<?php
命名空间 Illuminate\Foundation;
使用 Illuminate\Filesystem\Filesystem; 使用 Illuminate\Contracts\Foundation\Application 作为 ApplicationContract;
类 ProviderRepository { /** * 应用程序实现。 * * @var\Illuminate\Contracts\Foundation\Application */ protected $app;
/**
* The filesystem instance.
*
* @var \Illuminate\Filesystem\Filesystem
*/
protected $files;
/**
* The path to the manifest file.
*
* @var string
*/
protected $manifestPath;
/**
* Create a new service repository instance.
*
* @param \Illuminate\Contracts\Foundation\Application $app
* @param \Illuminate\Filesystem\Filesystem $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($this->createProvider($provider));
}
$this->app->setDeferredServices($manifest['deferred']);
}
/**
* 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;
}
$app = $this->app;
$app->make('events')->listen($events, function () use ($app, $provider) {
$app->register($provider);
});
}
/**
* Compile the application 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 new provider instance.
*
* @param string $provider
* @return \Illuminate\Support\ServiceProvider
*/
public function createProvider($provider)
{
return new $provider($this->app);
}
/**
* 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;
}
/**
* Load the service provider manifest JSON file.
*
* @return array
*/
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 = json_decode($this->files->get($this->manifestPath), true);
return array_merge(['when' => []], $manifest);
}
}
/**
* Write the service manifest file to disk.
*
* @param array $manifest
* @return array
*/
public function writeManifest($manifest)
{
$this->files->put(
$this->manifestPath, json_encode($manifest, JSON_PRETTY_PRINT)
);
return $manifest;
}
/**
* Create a fresh service manifest data structure.
*
* @param array $providers
* @return array
*/
protected function freshManifest(array $providers)
{
return ['providers' => $providers, 'eager' => [], 'deferred' => []];
}
Composer .json
{
"name": "laravel/laravel",
"description": "The Laravel Framework.",
"keywords": ["framework", "laravel"],
"license": "MIT",
"type": "project",
"require": {
"php": ">=5.5.9",
"laravel/framework": "5.1.*",
"intervention/image": "dev-master"
},
"require-dev": {
"fzaninotto/faker": "~1.4",
"mockery/mockery": "0.9.*",
"phpunit/phpunit": "~4.0",
"phpspec/phpspec": "~2.1"
},
"autoload": {
"classmap": [
"database",
"app/Models"
],
"psr-4": {
"App\\": "app/"
}
},
"autoload-dev": {
"classmap": [
"tests/TestCase.php"
]
},
"scripts": {
"post-install-cmd": [
"php artisan clear-compiled",
"php artisan optimize"
],
"post-update-cmd": [
"php artisan clear-compiled",
"php artisan optimize"
],
"post-root-package-install": [
"php -r \"copy('.env.example', '.env');\""
],
"post-create-project-cmd": [
"php artisan key:generate"
]
},
"config": {
"preferred-install": "dist"
},
"require": {
"illuminate/html": "5.*"
},
"minimum-stability": "dev",
"prefer-stable": true
最佳答案
我会尝试删除 ::class
。
这个设置对我有用:
'providers' => [
'Intervention\Image\ImageServiceProvider',
],
'aliases' => [
'Image' => 'Intervention\Image\Facades\Image',
]
关于php - 干预 laravel 5,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30879512/
我想使用 Intervention 两次调整图像大小。 我目前有这个: $img = Image::make($image_url); $img_path = public_path() . '/im
我正在尝试安装干预。我运行这个命令 Composer 需要干预/图片并且 composer.json 已更新。我在 $aliases 数组中添加 'Image' => 'Intervention\Im
我正在尝试在 Laravel 5.1 中添加个人资料图片上传。我使用了 Intervention/Image 包,但是当我尝试上传图像时出现此错误: NotReadableException in A
我在使用 Intervention/image 时遇到问题,Laravel #composer install - intervention/image 2.1.1 requires ext-file
标题中的这一点很难解释,如果有人想更改它也没关系。 我遇到过这样的情况,在 WPF 中,我创建了一个对程序员透明的“隐藏”窗口。我的意思是,这个窗口是在静态构造函数中创建的,隐藏并移动到屏幕之外,它的
我正在制作一个电子商务门户网站。我正在尝试以不同的分辨率上传图像,但效果很好。 但问题是,如果我在上传后在浏览器中查看它,我会看到模糊的图像,这不是我想要的。我希望上传后的图像应该清晰可见,不应该模糊
我是 Android 新手。我有一个想法,可以在安装所需应用程序的同时丰富用户的知识。这个想法是开发一个应用程序,可以分析应用程序的 .apk 文件以检查它是否过度特权。并通知用户他正在尝试安装的此应
我在从 master rebase 到我的一个存储库中的“部署”分支时遇到问题。 我的仓库设置如下: master - of course, the main branch deploy - a br
我想不通。当我像这样调整上传图片的大小时, public function up(Request $request) { $user = $request->user(); $imag
我正在使用 intervention/image 2.3 .当我尝试上传图片时,出现以下错误: InvalidArgumentException in AbstractEncoder.php line
我是一名优秀的程序员,十分优秀!