Closed jbidad closed 2 days ago
I am closing this pull request because it lacks sufficient explanation, tests, or both. It is difficult for us to merge pull requests without these things because the change may introduce breaking changes to the framework.
Feel free to re-submit your change with a thorough explanation of the feature and tests - integration tests are preferred over unit tests. Please include it's benefit to end users; the reasons it does not break any existing features; how it makes building web applications easier, etc.
Thanks!
I believe the explanation provided is sufficient. However, as mentioned earlier, this PR has not been validated by the existing tests since they rely on external packages. Additionally, this is related to issue number #53577
Let me know if you need further refinements! @taylorotwell
This PR enhances Laravel's route caching by transitioning from a stub-based mechanism to serialized data. This change addresses issues encountered during deployments and high-concurrency environments, improving performance and reliability.
Summary of Changes:
Route Caching Optimization:
buildRouteCacheFile
to serialize route data instead of generating a PHP stub.Adjustments in
RouteServiceProvider
:getCachedRoutes
to safely read and unserialize cached route files.loadCachedRoutes
to load routes directly from the deserialized cache usingRouter::setCompiledRoutes
.Tests Adjustments in
RouteCachingTest.php
:RouteCachingTest.php
to adapt to the new serialized route caching format.defineCacheRoutes
method used inOrchestra\Testbench\TestCase
to work with the serialized route cache instead of relying on PHP stubs.Orchestra\Testbench
.For instance, the
defineCacheRoutes
method now verifies that routes can be serialized, cached, and correctly restored without relying on stub-based logic.Backward Compatibility with Existing Tests:
route:cache
androute:clear
commands were enhanced to confirm correct behavior under various scenarios.Why This Change is Needed:
The previous stub-based caching system was prone to errors during high-load deployment scenarios, such as CI/CD pipelines, due to file generation and inclusion inconsistencies. Serialized route caching addresses this by:
Steps to Test:
php artisan route:cache
to generate cached routes.php artisan route:clear
removes the cached file as expected.Orchestra\Testbench\TestCase
.Backward Compatibility:
Impact:
Orchestra\Testbench
.Additional Context:
This update simplifies route caching logic and integrates well with
Orchestra\Testbench
workflows, ensuring Laravel applications benefit from a robust and reliable caching mechanism even under high load.