安装jenssegers/blade ~1.4.0后安装illuminate/database illuminate/pagination illuminate/events报错,应该指定哪个版本呢?

古树

按照官方的文档安装 psr/container ^v1 和 jenssegers/blade ~1.4.0后再安装illuminate/database,始终不成功,报错:

composer require -W illuminate/database illuminate/pagination illuminate/events
Using version ^9.12 for illuminate/database
Using version ^9.12 for illuminate/pagination
Using version ^9.12 for illuminate/events
./composer.json has been updated
Running composer update illuminate/database illuminate/pagination illuminate/events --with-all-dependencies
Loading composer repositories with package information
Updating dependencies
Your requirements could not be resolved to an installable set of packages.

Problem 1

  • Root composer.json requires illuminate/events ^9.12, found illuminate/events[v9.12.0, v9.12.1, v9.12.2] but these were not loaded, likely because it conflicts with another require.
    Problem 2
  • Root composer.json requires illuminate/database ^9.12 -> satisfiable by illuminate/database[v9.12.0, v9.12.1, v9.12.2].
  • illuminate/database[v9.12.0, ..., v9.12.2] require illuminate/collections ^9.0 -> found illuminate/collections[v9.0.0, ..., v9.12.2] but these were not loaded, likely because it conflicts with another require.
    Problem 3
  • Root composer.json requires illuminate/pagination ^9.12 -> satisfiable by illuminate/pagination[v9.12.0, v9.12.1, v9.12.2].
  • illuminate/pagination[v9.12.0, ..., v9.12.2] require illuminate/collections ^9.0 -> found illuminate/collections[v9.0.0, ..., v9.12.2] but these were not loaded, likely because it conflicts with another require.
    Problem 4
  • illuminate/view v8.83.12 requires illuminate/events ^8.0 -> found illuminate/events[v8.0.0, ..., v8.83.12] but it conflicts with your root composer.json require (^9.12).
  • jenssegers/blade v1.4.0 requires illuminate/view ^5.5|^6.0|^7.0|^8.0 -> satisfiable by illuminate/view[v8.83.12].
  • jenssegers/blade is locked to version v1.4.0 and an update of this package was not requested.

You can also try re-running composer require with an explicit version constraint, e.g. "composer require illuminate/database:*" to figure out if any version is installable, or "composer require illuminate/database:^2.1" if you know which you need.

Installation failed, reverting ./composer.json and ./composer.lock to their original content.

系统:windows 11
PHP: 8.1.2
Composer: 2.3.5
composer.json如下


  "require": {
    "php": ">=7.2",
    "workerman/webman-framework": "^1.3.13",
    "monolog/monolog": "^3.0.0",
    "psr/container": "v1",
    "jenssegers/blade": "^1.4"
  },
  "suggest": {
    "ext-event": "For better performance. "
  },
  "autoload": {
    "psr-4": {
      "": "./",
      "App\\": "./app"
    },
    "files": [
      "./support/helpers.php"
    ]
  },
  "scripts": {
    "post-package-install": [
      "support\\Plugin::install"
    ],
    "post-package-update": [
      "support\\Plugin::install"
    ],
    "pre-package-uninstall": [
      "support\\Plugin::uninstall"
    ]
  }

貌似是跟psr/container ^v1 jenssegers/blade ~1.4.0 冲突!!!!
各种版本间冲突太折磨人了。。
肿么办啊???

1413 4 0
4个回答

liziyu

下面的两个扩展版本。

    "illuminate/redis": "^9.4",
    "illuminate/database": "^9.4",

我安装的是这个版本。
php8.0.8 版。

composer info 如下:

illuminate/collections           v9.11.0 The Illuminate Collections package.
illuminate/conditionable         v9.11.0 The Illuminate Conditionable package.
illuminate/container             v9.11.0 The Illuminate Container package.
illuminate/contracts             v9.11.0 The Illuminate Contracts package.
illuminate/database              v9.11.0 The Illuminate Database package.
illuminate/macroable             v9.11.0 The Illuminate Macroable package.
illuminate/redis                 v9.11.0 The Illuminate Redis package.
illuminate/support               v9.11.0 The Illuminate Support package.
  • 古树 2022-05-17

    看来还是illuminate的靠谱,虽然没有解决我的问题

  • 古树 2022-05-17

    你用blade 视图了吗?用的哪个依赖什么版本?

  • liziyu 2022-05-17

    没用blade,用的是php原生语法作为模版。

  • 古树 2022-05-17

    我也用php原生语法,可是没有模板继承,这点让我很不爽

  • liziyu 2022-05-17

    include 呵呵。

latin

按照提示加个-W参数试下,composer require -W illuminate/database illuminate/pagination illuminate/events

  • 古树 2022-05-17

    没能解决~~

  • latin 2022-05-17

    再按照提示 composer require illuminate/database:*

  • 古树 2022-05-17

    这样是可以,就放弃9版本了,就没有以后了~ -_-||

古树

如果安装了psr/container ^v1 和 jenssegers/blade ~1.4.0, illuminate/redis也同样安装不了
强烈建议放弃拥抱jenssegers/blade吧,它已经不更新了

  • 暂无评论
古树

我的终极解决方案:
用 standalone-blade(https://github.com/ryangjchandler/standalone-blade )取代了jenssegers/blade。供大家参考~


use Illuminate\Config\Repository;
use Illuminate\Events\Dispatcher;
use Illuminate\Container\Container;
use Illuminate\Filesystem\Filesystem;
use Illuminate\Contracts\Container\Container as ContainerContract;
use Illuminate\Contracts\View\Factory;
use Illuminate\Support\Arr;
use Illuminate\Support\Facades\Facade;
use Illuminate\View\Compilers\BladeCompiler;
use Illuminate\View\ViewServiceProvider;

/**
 * @mixin \Illuminate\Contracts\View\Factory
 * @mixin \Illuminate\View\Compilers\BladeCompiler
 */
class Blade
{
    protected Factory $factory;

    protected BladeCompiler $compiler;

    final public function __construct(
        protected string|array $viewPaths,
        protected string $cachePath,
        protected ?ContainerContract $container = null
    ) {
        $this->viewPaths = Arr::wrap($viewPaths);

        $this->init();
    }

    protected function init()
    {
        $this->container ??= new Container;

        $this->container->singleton('files', fn () => new Filesystem);
        $this->container->singleton('events', fn () => new Dispatcher);
        $this->container->singleton('config', fn () => new Repository([
            'view.paths' => $this->viewPaths,
            'view.compiled' => $this->cachePath,
        ]));

        (new ViewServiceProvider($this->container))->register();

        $this->factory = $this->container->get('view');
        $this->compiler = $this->container->get('blade.compiler');
    }

    public function __call(string $name, array $arguments)
    {
        if (method_exists($this->compiler, $name)) {
            return $this->compiler->{$name}(...$arguments);
        }

        return $this->factory->{$name}(...$arguments);
    }

    public static function new(string $viewPath, string $cachePath, ?ContainerContract $container = null)
    {
        return new static($viewPath, $cachePath, $container);
    }

    public function render(string $viewPath, array $arguments = []): string
    {
        return $this->make($viewPath, $arguments);
    }
}
  • 暂无评论
年代过于久远,无法发表回答
×
🔝