Add route caching (PHP 8.4 compatible)#22
Merged
Conversation
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.
Ringkasan
Menambahkan route caching ke framework, di-port dari MaartenStaa/laravel-41-route-caching dan disesuaikan agar jalan di PHP 8.4 — menggantikan dependency package yang sudah abandoned (2015) dan fatal di 8.4 karena implicit-nullable parameter.
Ditempatkan di namespace baru
Illuminate\CachedRouting(opt-in), sehingga coreIlluminate\Routingtidak tersentuh.Mekanisme
Route::cache(__FILE__, function () { ... })membungkus definisi route. Isi collection di-serialize()ke cache store (Redis/file), di-key per file. Pada request berikutnya route dipulihkan dari cache tanpa menjalankan ulang callback — closure controller dibangun lazy saat dispatch, sehingga route tetap serializable.Illuminate\CachedRouting\Router—cache(),clearCache(), keeps controller action sbg stringIlluminate\CachedRouting\Route— precompile via__sleep(), reuse compiled routeIlluminate\CachedRouting\RouteCollection— save/restore/serialize helpersIlluminate\CachedRouting\RoutingServiceProvider— swaprouter(daftarkan di config app)Perubahan vs package asli
?Container(implicit-nullable → explicit) — akar bug yang bikin package asli tidak jalanHttpKernelBrowser,createMock,expectException)Cara pakai
Daftarkan provider di
app/config/app.php:'Illuminate\CachedRouting\RoutingServiceProvider',lalu bungkus route:
Testing
tests/CachedRouting/— 12 test, 41 assertion, lulus di PHP 8.4🤖 Generated with Claude Code