5

I'm trying to install Sylius 1.8 on ubuntu and I follow installation guide when I run composer install I get following error:

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

I have also used Sylius docker but the result was the same, it seems there is an issue with Api-Platform.

yivi
  • 42,438
  • 18
  • 116
  • 138
  • Please share more details. If this is a generic problem directly after installing a software, it would be better to post this in the issue tracker of that software – Nico Haase Jan 24 '21 at 11:16

2 Answers2

9

Sylius uses Api-Platform, and very recently version 2.6 of Api-Platform was released.

Since this release, all API resources —including custom DTOs— need to have an "identifier", as other users are finding out.

There already exists a PR to fix this to make Sylius compatible with Api-Platform 2.6.0.

If you are installing a brand new project, you could do the following to install Sylius from scratch:

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

If you have an existing project you need to fix before updating (even one you've installed following the instructions on the previous step), you should add this to the conflict key of your composer.json:

{
    "conflict":  {
        "api-platform/core": ">=2.6.0"
    }
}

Although you should monitor the development of Sylius to remove this line once is no longer needed.

yivi
  • 42,438
  • 18
  • 116
  • 138
  • Shouldn't it be `"api-platform/core": ">=2.6.0"` for the conflict key? Since this thread is referenced from the github issue it would be nice if you can fix it in your answer :) – csc Jan 27 '21 at 11:04
  • Thanks, multitasking gets the best of us. And me as well. – yivi Jan 27 '21 at 11:05
-1

Sylius uses Api-Platform, and very recently version 2.6 of Api-Platform was released.

Since this release, all API resources —including custom DTOs— need to have an "identifier", as other users are finding out.

There already exists a PR to fix this to make Sylius compatible with Api-Platform 2.6.0.

If you are installing a brand new project, you could do the following to install Sylius from scratch:

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 If you have an existing project you need to fix before updating, you could add this to the conflict key of your composer.json:

{ "conflict": { "api-platform": ">=2.6.0" } } Although you should monitor the development of Sylius to remove this line once is no longer needed.

I work for me, however there is an error on the conflict package for update

"conflict": {
    "symfony/form": "4.4.11|4.4.12",
    "api-platform/core": ">=2.6.0"
},
Arnaud Bagnis
  • 142
  • 2
  • 9