Repository navigation
Port to Craft 6 (native, adapter-free) via craft-6-plugin-porting skill - #204
Draft
lukeholder wants to merge 1 commit into
Draft
lukeholder wants to merge 1 commit into
lukeholder wants to merge 1 commit into
Conversation
… skill - Requires craftcms/cms ^6.0.0 and PHP ^8.5; no craftcms/yii2-adapter - Moves to the CraftCms\ElementApi namespace with Laravel-style folders - Native Plugin and PluginSettings; endpoints from config/craft/element-api.php are registered as Laravel routes - Invokable ElementApiController; caching uses ElementCaches and the dependency-aware cache, with cacheDuration as the default TTL - Response headers via ResponseHeaders::add(); API responses no longer set cookies - DataEvent / EVENT_BEFORE_SEND_DATA replaced by the SendingData event - Adds UPGRADE.md; updates the README and CHANGELOG Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Ports Element API to Craft 6 as a fully native plugin. It does not require
craftcms/yii2-adapter.craftcms/cms ^6.0.0and PHP^8.5.CraftCms\ElementApinamespace with Laravel-style folders (Http/Controllers,Events,Contracts,Resources,Transformers,Serializers,Support).Pluginbase class andPluginSettings. The endpoints inconfig/craft/element-api.phpare registered as Laravel routes at boot, using Laravel route syntax (news/{entryId}.json). Endpoint functions can type-hintIlluminate\Http\Request, andint-hinted parameters only match digits.DefaultControlleris now an invokableElementApiController. Response caching usesElementCachesand the dependency-aware cache (still taggedelement-api, and invalidated when an element is saved).cache: trueuses thecacheDurationsetting as its TTL, as before.ResponseHeaders::add(). API responses no longer set cookies.DataEventandEVENT_BEFORE_SEND_DATAare replaced by theSendingDataLaravel event (clean break, no compatibility layer).generateTransformsBeforePageLoadoverride, thepathParamguard and the Yii PHPStan stub.UPGRADE.mdand updates the README and CHANGELOG.Testing
Tested in a Craft 6.0.0-alpha.20 host with no adapter and no
yiisoft/yii2:OPTIONSpreflight with a CORS header set from an endpoint function, 404 and 500 JSON error responses, noSet-Cookie,X-Robots-Tag: noneyii\helpers\Jsonon<,&, quotes, slashes and unicodepaginate: false,contentType,pretty,resourceKey,meta,pageParam, and thedataArrayandjsonApiserializersRequestinjection into an endpoint function, the deprecatedfirstsetting, an invalidelementTypeSendingDataevent, the Clear Caches option, a request from a logged-in adminNot verified / follow-ups
ecs.php,phpstan.neon, the dev dependencies,composer.lockand.github/workflows/ci.ymlstill target Craft 4/5.includesandexcludes(the README example), a customclassresource, the live-preview cache bypass, and serving requests from a route cache (route:cacheitself ran fine).php artisan config:cachefails in a project that uses endpoint functions, because closures can't be serialized (documented in the README andUPGRADE.md).5.xbranch, so the PR targets4.x.🤖 Generated with Claude Code