Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[api-platform/core] Support for v3.4 and v4 #1339

Merged
merged 4 commits into from
Sep 27, 2024

Conversation

dunglas
Copy link
Member

@dunglas dunglas commented Sep 23, 2024

Q A
License MIT
Doc issue/PR n/a
  • Support for the subtree split (the bundle is now available in a standalone package in addition to as part of core: api-platform/symfony
  • Simplified configuration

Closes api-platform/core#6631

Copy link

github-actions bot commented Sep 23, 2024

Thanks for the PR 😍

How to test these changes in your application

  1. Define the SYMFONY_ENDPOINT environment variable:

    # On Unix-like (BSD, Linux and macOS)
    export SYMFONY_ENDPOINT=https://raw.githubusercontent.com/symfony/recipes/flex/pull-1339/index.json
    # On Windows
    SET SYMFONY_ENDPOINT=https://raw.githubusercontent.com/symfony/recipes/flex/pull-1339/index.json
  2. Install the package(s) related to this recipe:

    composer req 'symfony/flex:^1.16'
    composer req 'api-platform/core:^4.0' 'api-platform/symfony:^4.0'
  3. Don't forget to unset the SYMFONY_ENDPOINT environment variable when done:

    # On Unix-like (BSD, Linux and macOS)
    unset SYMFONY_ENDPOINT
    # On Windows
    SET SYMFONY_ENDPOINT=

Diff between recipe versions

In order to help with the review stage, I'm in charge of computing the diff between the various versions of patched recipes.
I'm going keep this comment up to date with any updates of the attached patch.

api-platform/core

2.1 vs 2.5
diff --git a/api-platform/core/2.1/config/packages/api_platform.yaml b/api-platform/core/2.5/config/packages/api_platform.yaml
index e453d1d..2eb7b4c 100644
--- a/api-platform/core/2.1/config/packages/api_platform.yaml
+++ b/api-platform/core/2.5/config/packages/api_platform.yaml
@@ -1,3 +1,7 @@
 api_platform:
     mapping:
         paths: ['%kernel.project_dir%/src/Entity']
+    patch_formats:
+        json: ['application/merge-patch+json']
+    swagger:
+        versions: [3]
2.5 vs 3.0
diff --git a/api-platform/core/2.5/config/packages/api_platform.yaml b/api-platform/core/2.5/config/packages/api_platform.yaml
deleted file mode 100644
index 2eb7b4c..0000000
--- a/api-platform/core/2.5/config/packages/api_platform.yaml
+++ /dev/null
@@ -1,7 +0,0 @@
-api_platform:
-    mapping:
-        paths: ['%kernel.project_dir%/src/Entity']
-    patch_formats:
-        json: ['application/merge-patch+json']
-    swagger:
-        versions: [3]
diff --git a/api-platform/core/2.5/manifest.json b/api-platform/core/3.0/manifest.json
index a886a48..af16452 100644
--- a/api-platform/core/2.5/manifest.json
+++ b/api-platform/core/3.0/manifest.json
@@ -1,6 +1,6 @@
 {
     "bundles": {
-        "ApiPlatform\\Core\\Bridge\\Symfony\\Bundle\\ApiPlatformBundle": ["all"]
+        "ApiPlatform\\Symfony\\Bundle\\ApiPlatformBundle": ["all"]
     },
     "copy-from-recipe": {
         "config/": "%CONFIG_DIR%/",
diff --git a/api-platform/core/2.5/src/Entity/.gitignore b/api-platform/core/3.0/src/ApiResource/.gitignore
similarity index 100%
rename from api-platform/core/2.5/src/Entity/.gitignore
rename to api-platform/core/3.0/src/ApiResource/.gitignore
3.0 vs 3.1
diff --git a/api-platform/core/3.1/config/packages/api_platform.yaml b/api-platform/core/3.1/config/packages/api_platform.yaml
new file mode 100644
index 0000000..41c7993
--- /dev/null
+++ b/api-platform/core/3.1/config/packages/api_platform.yaml
@@ -0,0 +1,10 @@
+api_platform:
+    title: Hello API Platform
+    version: 1.0.0
+    # Good defaults for REST APIs
+    defaults:
+        stateless: true
+        cache_headers:
+            vary: ['Content-Type', 'Authorization', 'Origin']
+        extra_properties:
+            standard_put: true
3.1 vs 3.2
diff --git a/api-platform/core/3.1/config/packages/api_platform.yaml b/api-platform/core/3.2/config/packages/api_platform.yaml
index 41c7993..4d0c3f7 100644
--- a/api-platform/core/3.1/config/packages/api_platform.yaml
+++ b/api-platform/core/3.2/config/packages/api_platform.yaml
@@ -1,10 +1,18 @@
 api_platform:
     title: Hello API Platform
     version: 1.0.0
-    # Good defaults for REST APIs
+    formats:
+        jsonld: ['application/ld+json']
+    docs_formats:
+        jsonld: ['application/ld+json']
+        jsonopenapi: ['application/vnd.openapi+json']
+        html: ['text/html']
     defaults:
         stateless: true
         cache_headers:
             vary: ['Content-Type', 'Authorization', 'Origin']
         extra_properties:
             standard_put: true
+            rfc_7807_compliant_errors: true
+    event_listeners_backward_compatibility_layer: false
+    keep_legacy_inflector: false
3.2 vs 3.3
diff --git a/api-platform/core/3.2/config/packages/api_platform.yaml b/api-platform/core/3.3/config/packages/api_platform.yaml
index 4d0c3f7..e4233dc 100644
--- a/api-platform/core/3.2/config/packages/api_platform.yaml
+++ b/api-platform/core/3.3/config/packages/api_platform.yaml
@@ -14,5 +14,5 @@ api_platform:
         extra_properties:
             standard_put: true
             rfc_7807_compliant_errors: true
-    event_listeners_backward_compatibility_layer: false
     keep_legacy_inflector: false
+    use_symfony_listeners: true
3.3 vs 4.0
diff --git a/api-platform/core/3.3/config/packages/api_platform.yaml b/api-platform/core/4.0/config/packages/api_platform.yaml
index e4233dc..02f295a 100644
--- a/api-platform/core/3.3/config/packages/api_platform.yaml
+++ b/api-platform/core/4.0/config/packages/api_platform.yaml
@@ -1,18 +1,7 @@
 api_platform:
     title: Hello API Platform
     version: 1.0.0
-    formats:
-        jsonld: ['application/ld+json']
-    docs_formats:
-        jsonld: ['application/ld+json']
-        jsonopenapi: ['application/vnd.openapi+json']
-        html: ['text/html']
     defaults:
         stateless: true
         cache_headers:
             vary: ['Content-Type', 'Authorization', 'Origin']
-        extra_properties:
-            standard_put: true
-            rfc_7807_compliant_errors: true
-    keep_legacy_inflector: false
-    use_symfony_listeners: true

api-platform/symfony

3.3 vs 4.0
diff --git a/api-platform/symfony/3.3/config/packages/api_platform.yaml b/api-platform/symfony/4.0/config/packages/api_platform.yaml
index e4233dc..02f295a 100644
--- a/api-platform/symfony/3.3/config/packages/api_platform.yaml
+++ b/api-platform/symfony/4.0/config/packages/api_platform.yaml
@@ -1,18 +1,7 @@
 api_platform:
     title: Hello API Platform
     version: 1.0.0
-    formats:
-        jsonld: ['application/ld+json']
-    docs_formats:
-        jsonld: ['application/ld+json']
-        jsonopenapi: ['application/vnd.openapi+json']
-        html: ['text/html']
     defaults:
         stateless: true
         cache_headers:
             vary: ['Content-Type', 'Authorization', 'Origin']
-        extra_properties:
-            standard_put: true
-            rfc_7807_compliant_errors: true
-    keep_legacy_inflector: false
-    use_symfony_listeners: true
diff --git a/api-platform/symfony/3.3/post-install.txt b/api-platform/symfony/4.0/post-install.txt
index 613c2b8..82bb10a 100644
--- a/api-platform/symfony/3.3/post-install.txt
+++ b/api-platform/symfony/4.0/post-install.txt
@@ -4,7 +4,7 @@
 
   * Using MakerBundle? Try php bin/console make:entity --api-resource 
 
-  * To enable the GraphQL support, run composer require webonyx/graphql-php,
+  * To enable the GraphQL support, run composer require api-platform/graphql,
     then browse /api/graphql.
 
   * Read the documentation at https://api-platform.com/docs/

@stof
Copy link
Member

stof commented Sep 23, 2024

Why is the PR title saying it is about support v4 when the recipe is for 3.4 ?

@dunglas dunglas changed the title [api-platform/core] Support for v4 [api-platform/core] Support for v3.4 and v4 Sep 23, 2024
Copy link
Contributor

@jrushlow jrushlow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me - merging will allow us to revert symfony/maker-bundle#1598 over in MakerBundle

@dunglas
Copy link
Member Author

dunglas commented Sep 25, 2024

Good catch @stof, I checked with @soyuka and my recipe was faulty in 3.4. It if fixed now.

@chalasr
Copy link
Member

chalasr commented Sep 25, 2024

@@ -0,0 +1,9 @@
{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't it conflict with api-platform/core < 4.0 ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WDYT @soyuka?

@dunglas
Copy link
Member Author

dunglas commented Sep 26, 2024

@chalasr This is because API Platform 4 requires PHP 8.2+. We forgot to bump the minimum version in composer.json in 4.0.0 before tagging (but the code was broken with php <8.2) and now Composer always tries to install this broken version with PHP 8.1. Maybe should we delete the 4.0.0 tag, but it will cause other kinds of issues.

For now I suggest to just merge as-is.

@dunglas
Copy link
Member Author

dunglas commented Sep 27, 2024

@chalasr we finally fixed it by rewriting the tags.

@symfony-recipes-bot symfony-recipes-bot merged commit f8a696d into symfony:main Sep 27, 2024
1 of 2 checks passed
@dunglas dunglas deleted the api-platform-4 branch September 27, 2024 13:35
jrushlow added a commit to jrushlow/maker-bundle that referenced this pull request Sep 28, 2024
symfony/recipes#1339 is now merged - we dont need to skip these tests anymore.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Symfony Flex recipes missing for 4.x branch
7 participants