问题描述
我正在尝试在 ubuntu 上安装 Sylius 1.8,并且在运行 composer install
时按照安装指南进行操作,但出现以下错误:
Run composer recipes at any time to see the status of your Symfony recipes.
Executing script cache:clear [KO]
[KO]
Script cache:clear returned with error code 1
!!
!! // Clearing the cache for the prod environment with debug
!! // false
!!
!!
!! In FileLoader.PHP line 180:
!!
!! No identifier defined "Sylius\Bundle\ApiBundle\Command\RegisterShopUser". Y
!! ou should add #[\ApiPlatform\Core\Annotation\ApiProperty(identifier: true)]
!! " on the property identifying the resource." in . (which is being imported
!! from "/srv/sylius/vendor/sylius/sylius/src/Sylius/Bundle/ApiBundle/Resource
!! s/config/routing.yml"). Make sure there is a loader supporting the "api_pla
!! tform" type.
!!
!!
!! In IdentifiersExtractor.PHP line 65:
!!
!! No identifier defined "Sylius\Bundle\ApiBundle\Command\RegisterShopUser". Y
!! ou should add #[\ApiPlatform\Core\Annotation\ApiProperty(identifier: true)]
!! " on the property identifying the resource."
!!
!!
!! cache:clear [--no-warmup] [--no-optional-warmers] [-h|--help] [-q|--quiet] [-v|vv|vvv|--verbose] [-V|--version] [--ansi] [--no-ansi] [-n|--no-interaction] [-e|--env ENV] [--no-debug] [--] <command>
!!
!!
Script @auto-scripts was called via post-install-cmd
我也使用过 Sylius docker 但结果是一样的,似乎 Api-Platform 有问题。
解决方法
Sylius 使用 Api-Platform,最近发布了 Api-Platform 2.6 版。
自此版本以来,所有 API 资源(包括自定义 DTO)都需要有一个“标识符”as other users are finding out。
已经有exists a PR to fix this to make Sylius compatible with Api-Platform 2.6.0。
如果您正在安装一个全新的项目,您可以执行以下操作来从头安装 Sylius:
composer create-project sylius/sylius-standard app_dir --no-install --no-scripts
cd app_dir
composer require api-platform/core:2.5.9 --no-update
composer install
如果您有一个需要在更新前修复的现有项目(即使是按照上一步的说明安装的项目),您应该将其添加到您的 conflict
的 composer.json
键中:
{
"conflict": {
"api-platform/core": ">=2.6.0"
}
}
尽管您应该监控 Sylius 的开发以删除此行不再需要。
,Sylius 使用 Api-Platform,以及最近的 2.6 版 Api-Platform 发布。
自此版本以来,所有 API 资源(包括自定义 DTO)都需要 有一个“标识符”,正如其他用户所发现的那样。
已经存在一个 PR 来解决这个问题,使 Sylius 与 Api-Platform 2.6.0.
如果您正在安装一个全新的项目,您可以执行以下操作 从头开始安装 Sylius:
作曲家创建项目 sylius/sylius-standard app_dir --no-install --no-scripts cd app_dir composer require api-platform/core:2.5.9 --no-update composer install 如果您有一个现有项目需要在更新前修复,您可以将其添加到您的冲突键中 composer.json:
{ “冲突”: { "api-platform": ">=2.6.0" 虽然您应该监控 Sylius 的开发以删除此行一次不再需要。
我为我工作,但是更新冲突包有错误
"conflict": {
"symfony/form": "4.4.11|4.4.12","api-platform/core": ">=2.6.0"
},