作曲家需要 symfony/assets 安装

composer require symfony/assets installation

我对 pimcore 比较陌生,很难获得合适的作曲家包。

首先我安装了pimcore

composer create-project pimcore/skeleton my-project

我将 TWIG 添加到项目中,因为它被推荐用于 symfony。 --> 所以我可以使用资产功能。 Symfony Asset

现在要包含文件,我想使用symfony的资产功能。但遗憾的是,“asset()”目前 return 没有任何路径。

{# the image lives at "public/images/logo.png" #}
<img src="{{ asset('images/logo.png') }}" alt="Symfony!"/>

所以我意识到,我必须安装资产包。但是每当我尝试添加要求时,我都会收到错误消息。我不确定是否需要将要求放在 pimcore 项目的 composer.json 文件中,或者放在 symfony/symfony 包的 composer.json 文件中。尽管如此,我在这两种情况下都会出错:

结果更新composer.json在项目根

  Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - Conclusion: remove pimcore/pimcore v6.8.1
    - Conclusion: don't install pimcore/pimcore v6.8.1
    - symfony/symfony v3.4.43 conflicts with pimcore/pimcore[v6.8.1].
    - symfony/symfony v4.4.11 conflicts with pimcore/pimcore[v6.8.1].
    - Conclusion: don't install symfony/asset v5.1.8
    - Conclusion: don't install symfony/asset v5.1.7
    - Conclusion: don't install symfony/asset v5.1.6
    - Conclusion: don't install symfony/asset v5.1.5
    - Conclusion: don't install symfony/asset v5.1.4
    - Conclusion: don't install symfony/asset v5.1.3
    - Conclusion: don't install symfony/asset v5.1.2
    - Installation request for pimcore/pimcore (locked at v6.8.1, required as ~6.8.0) -> satisfiable by pimcore/pimcore[v6.8.1].
    - Conclusion: don't install symfony/asset v5.1.1
    - pimcore/pimcore v6.8.1 requires symfony/symfony ^3.4.26 || ^4.1.12 -> satisfiable by symfony/symfony[v4.4.15, v3.4.26, v3.4.27, v3.4.28, v3.4.29, v3.4.30, v3.4.31, v3.4.32, v3.4.33, v3.4.34, v3.4.35, v3.4.36, v3.4.37, v3.4.38, v3.4.39, v3.4.40, v3.4.41, v3.4.42, v3.4.43, v3.4.44, v3.4.45, v3.4.46, v4.1.12, v4.1.13, v4.2.0, v4.2.1, v4.2.10, v4.2.11, v4.2.12, v4.2.2, v4.2.3, v4.2.4, v4.2.5, v4.2.6, v4.2.7, v4.2.8, v4.2.9, v4.3.0, v4.3.1, v4.3.10, v4.3.11, v4.3.2, v4.3.3, v4.3.4, v4.3.5, v4.3.6, v4.3.7, v4.3.8, v4.3.9, v4.4.0, v4.4.1, v4.4.10, v4.4.11, v4.4.12, v4.4.13, v4.4.14, v4.4.16, v4.4.2, v4.4.3, v4.4.4, v4.4.5, v4.4.6, v4.4.7, v4.4.8, v4.4.9].
    - don't install symfony/asset v5.1.0|don't install symfony/symfony v3.4.26
    - don't install symfony/asset v5.1.0|don't install symfony/symfony v3.4.27
    - don't install symfony/asset v5.1.0|don't install symfony/symfony v3.4.28
    - don't install symfony/asset v5.1.0|don't install symfony/symfony v3.4.29
    - don't install symfony/asset v5.1.0|don't install symfony/symfony v3.4.30
    - don't install symfony/asset v5.1.0|don't install symfony/symfony v3.4.31
    - don't install symfony/asset v5.1.0|don't install symfony/symfony v3.4.32
    - don't install symfony/asset v5.1.0|don't install symfony/symfony v3.4.33
    - don't install symfony/asset v5.1.0|don't install symfony/symfony v3.4.34
    - don't install symfony/asset v5.1.0|don't install symfony/symfony v3.4.35
    - don't install symfony/asset v5.1.0|don't install symfony/symfony v3.4.36
    - don't install symfony/asset v5.1.0|don't install symfony/symfony v3.4.37
    - don't install symfony/asset v5.1.0|don't install symfony/symfony v3.4.38
    - don't install symfony/asset v5.1.0|don't install symfony/symfony v3.4.39
    - don't install symfony/asset v5.1.0|don't install symfony/symfony v3.4.40
    - don't install symfony/asset v5.1.0|don't install symfony/symfony v3.4.41
    - don't install symfony/asset v5.1.0|don't install symfony/symfony v3.4.42
    - don't install symfony/asset v5.1.0|don't install symfony/symfony v3.4.44
    - don't install symfony/asset v5.1.0|don't install symfony/symfony v3.4.45
    - don't install symfony/asset v5.1.0|don't install symfony/symfony v3.4.46
    - don't install symfony/asset v5.1.0|don't install symfony/symfony v4.1.12
    - don't install symfony/asset v5.1.0|don't install symfony/symfony v4.1.13
    - don't install symfony/asset v5.1.0|don't install symfony/symfony v4.2.0
    - don't install symfony/asset v5.1.0|don't install symfony/symfony v4.2.1
    - don't install symfony/asset v5.1.0|don't install symfony/symfony v4.2.10
    - don't install symfony/asset v5.1.0|don't install symfony/symfony v4.2.11
    - don't install symfony/asset v5.1.0|don't install symfony/symfony v4.2.12
    - don't install symfony/asset v5.1.0|don't install symfony/symfony v4.2.2
    - don't install symfony/asset v5.1.0|don't install symfony/symfony v4.2.3
    - don't install symfony/asset v5.1.0|don't install symfony/symfony v4.2.4
    - don't install symfony/asset v5.1.0|don't install symfony/symfony v4.2.5
    - don't install symfony/asset v5.1.0|don't install symfony/symfony v4.2.6
    - don't install symfony/asset v5.1.0|don't install symfony/symfony v4.2.7
    - don't install symfony/asset v5.1.0|don't install symfony/symfony v4.2.8
    - don't install symfony/asset v5.1.0|don't install symfony/symfony v4.2.9
    - don't install symfony/asset v5.1.0|don't install symfony/symfony v4.3.0
    - don't install symfony/asset v5.1.0|don't install symfony/symfony v4.3.1
    - don't install symfony/asset v5.1.0|don't install symfony/symfony v4.3.10
    - don't install symfony/asset v5.1.0|don't install symfony/symfony v4.3.11
    - don't install symfony/asset v5.1.0|don't install symfony/symfony v4.3.2
    - don't install symfony/asset v5.1.0|don't install symfony/symfony v4.3.3
    - don't install symfony/asset v5.1.0|don't install symfony/symfony v4.3.4
    - don't install symfony/asset v5.1.0|don't install symfony/symfony v4.3.5
    - don't install symfony/asset v5.1.0|don't install symfony/symfony v4.3.6
    - don't install symfony/asset v5.1.0|don't install symfony/symfony v4.3.7
    - don't install symfony/asset v5.1.0|don't install symfony/symfony v4.3.8
    - don't install symfony/asset v5.1.0|don't install symfony/symfony v4.3.9
    - don't install symfony/asset v5.1.0|don't install symfony/symfony v4.4.0
    - don't install symfony/asset v5.1.0|don't install symfony/symfony v4.4.1
    - don't install symfony/asset v5.1.0|don't install symfony/symfony v4.4.10
    - don't install symfony/asset v5.1.0|don't install symfony/symfony v4.4.12
    - don't install symfony/asset v5.1.0|don't install symfony/symfony v4.4.13
    - don't install symfony/asset v5.1.0|don't install symfony/symfony v4.4.14
    - don't install symfony/asset v5.1.0|don't install symfony/symfony v4.4.15
    - don't install symfony/asset v5.1.0|don't install symfony/symfony v4.4.16
    - don't install symfony/asset v5.1.0|don't install symfony/symfony v4.4.2
    - don't install symfony/asset v5.1.0|don't install symfony/symfony v4.4.3
    - don't install symfony/asset v5.1.0|don't install symfony/symfony v4.4.4
    - don't install symfony/asset v5.1.0|don't install symfony/symfony v4.4.5
    - don't install symfony/asset v5.1.0|don't install symfony/symfony v4.4.6
    - don't install symfony/asset v5.1.0|don't install symfony/symfony v4.4.7
    - don't install symfony/asset v5.1.0|don't install symfony/symfony v4.4.8
    - don't install symfony/asset v5.1.0|don't install symfony/symfony v4.4.9
    - don't install symfony/asset v5.1.0|remove symfony/symfony v4.4.15
    - don't install symfony/asset v5.1.0|don't install symfony/symfony v4.4.15
    - Installation request for symfony/asset ^5.1 -> satisfiable by symfony/asset[v5.1.0, v5.1.1, v5.1.2, v5.1.3, v5.1.4, v5.1.5, v5.1.6, v5.1.7, v5.1.8].


Installation failed, reverting ./composer.json to its original content.

symfony 包 (/vendor/symfony/symfony) 的结果更新 composer.json - 但我认为这是错误的

    Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - Installation request for symfony/symfony No version set (parsed as 1.0.0) -> satisfiable by symfony/symfony[No version set (parsed as 1.0.0)].
    - don't install symfony/asset 5.x-dev|remove symfony/symfony No version set (parsed as 1.0.0)
    - Installation request for symfony/asset 5.x-dev -> satisfiable by symfony/asset[5.x-dev].


Installation failed, reverting ./composer.json to its original content.

抱歉这个愚蠢的问题。 谢谢你帮助我。


编辑 1: 这是我的 composer.json 项目文件

{
"name": "pimcore/skeleton",
  "type": "project",
  "license": "GPL-3.0-or-later",
  "config": {
    "optimize-autoloader": true,
    "sort-packages": true
  },
  "require": {
    "php": ">=7.2",
    "wikimedia/composer-merge-plugin": "^1.4",
    "pimcore/pimcore": "~6.8.0"
  },
  "require-dev": {
    "cache/integration-tests": "^0.16.0",
    "codeception/codeception": "~2.4.5"
  },
  "autoload": {
    "psr-4": {
      "": ["src/"],
      "Pimcore\Model\DataObject\": "var/classes/DataObject",
      "Pimcore\Model\Object\": "var/classes/Object",
      "Website\": "legacy/website/lib"
    },
    "classmap": [
      "app/AppKernel.php"
    ]
  },
  "scripts": {
    "post-create-project-cmd": "Pimcore\Composer::postCreateProject",
    "post-install-cmd": [
      "Pimcore\Composer::postInstall",
      "@pimcore-scripts"
    ],
    "post-update-cmd": [
      "Pimcore\Composer::postUpdate",
      "@pimcore-scripts",
      "Pimcore\Composer::executeMigrationsUp",
      "@pimcore-scripts"
    ],
    "pimcore-scripts": [
      "Pimcore\Composer::clearCache",
      "Pimcore\Composer::installAssets"
    ]
  },
  "extra": {
    "symfony-app-dir": "app",
    "symfony-bin-dir": "bin",
    "symfony-var-dir": "var",
    "symfony-web-dir": "web",
    "symfony-tests-dir": "tests",
    "symfony-assets-install": "relative",
    "merge-plugin": {
      "include": [
        "composer.local.json"
      ],
      "recurse": true,
      "replace": true,
      "merge-dev": true,
      "merge-extra": false,
      "merge-extra-deep": false,
      "merge-scripts": false
    }
  }
}

编辑 2:

这是我使用的命令:

composer require symfony/asset

终于到了有趣的地步:正如错误消息告诉您的那样,symfony/symfony 已经安装(因为这是 pimcore/pimcore 的依赖项)。这个核心包包含 Symfony 的所有组件,安装一个单独的附加组件(如 symfony/asset)是不可能的。

如果您可以使用发布的图像标签 (<img src="{{ asset('images/logo.png') }}" alt="Symfony!"/>) 而不会在渲染过程中弹出任何错误消息(就:可以生成标记,即使图像的源未按预期生成) ,这也意味着安装了 asset 功能所需的 Twig 扩展。

因此,您的下一步是搜索缺少的资产配置以生成正确的图像 URL。