2

Following this tutorial I tried to configure REST API on fresh new Symfony 4 install.

The first step in the tutorial is doing:

composer create-project symfony/skeleton rest_api_project

Followed by

composer require friendsofsymfony/rest-bundle

However, when I try to install friendsofsymfony/rest-bundle, I get:

Your requirements could not be resolved to an installable set of packages. Problem 1 - Installation request for friendsofsymfony/rest-bundle ^2.6 -> satisfiable by friendsofsymfony/rest-bundle[2.6.0]. - friendsofsymfony/rest-bundle 2.6.0 requires symfony/config ^3.4|^4.3 -> no matching package found.

So basically that this bundle requires symfony/config ^3.4|^4.3 while Symfony 4 uses 5.0.

How to make it work? And how this tutorial meant for Symfony 4 could even work when the friendsofsymfony/rest-bundle does not support config in 5.0 version?

AppyGG
  • 381
  • 1
  • 6
  • 12
PolGraphic
  • 3,233
  • 11
  • 51
  • 108

1 Answers1

5

The tutorial you are using includes this as a starting point:

composer create-project \
    symfony/skeleton rest_api_project

Without a version constraint, this points to the latest version of the Symfony Skeleton. Namely, version 5.

Problem is, the FOS Rest Bundle has not been updated with Symfony 5 compatibility yet.

So you need to create the project and target version 4.

composer create-project\
    symfony/skeleton rest_api_project "4.*"

With this the versions of your dependencies are going to match.

And how this tutorial meant for Symfony 4 could even work when the friendsofsymfony/rest-bundle does not support config in 5.0 version?

The tutorial is meant for Symfony 4, but you were installing Symfony 5.

yivi
  • 42,438
  • 18
  • 116
  • 138
  • Ah! Yes, I've somehow omitted that few days ago there was Symfony 5 release. Somehow I was still sure 4 is the latest version. Thank you! – PolGraphic Nov 26 '19 at 08:55