Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Grease Laravel Package

onelearningcommunity/grease

Grease is a menu of independent, byte-identical performance tiers for Laravel's hot paths—Eloquent hydration, casting and serialization, events, Blade, config, validation, the container and router. Opt in per tier; the model trait is the zero-config starting point. Zero framework changes, and anythi...

View on GitHub
Deep Wiki
Context7

Opt-in performance for Laravel's hot paths. One trait, byte-identical output — and it really shines under Octane. Get greased.

Frequently asked questions about Grease
How do I install and enable Grease in a Laravel 10+ project?
Run `composer require onelearningcommunity/grease`, then add the service provider to `config/app.php` under `providers`. No additional configuration is needed—optimizations are opt-in via facade methods like `Grease::optimizeQuery()` or `Grease::hydrateLazy()`.
Which Laravel Eloquent operations does Grease optimize?
Grease targets the 'hot path' of Eloquent: query building (e.g., `where()`, `with()`), hydration (model instantiation), and eager loading. It avoids write operations, focusing on read-heavy workflows like APIs or admin dashboards.
Will Grease break existing Eloquent behavior or third-party packages?
No—Grease produces byte-identical output and doesn’t modify core Eloquent. However, packages that hook into internals (e.g., query observers, global scopes) *might* conflict. Test with `tntsearch/laravel-scout-dog` or Laravel Debugbar before full adoption.
Does Grease work with Laravel 9 or older versions?
Grease officially supports Laravel 10+. For older versions, you’d need to fork the package (not recommended) or upgrade Laravel. The effort is justified for performance-critical apps, as optimizations are minimal-risk due to zero-core changes.
How do I measure Grease’s impact on query performance?
Use Laravel Debugbar or Blackfire to compare pre/post-optimization metrics. Focus on hydration time (e.g., `Model::all()`) and eager loading (`with()`). For APIs, track response times with tools like New Relic or Datadog.
Are there any memory tradeoffs with Grease’s optimizations?
Some optimizations (e.g., lazy hydration) may increase memory usage for complex queries. Monitor with `laravel-debugbar` or Blackfire, especially in high-concurrency environments. Profile before enabling optimizations for critical models.
Can I A/B test Grease optimizations before full rollout?
Yes. Use feature flags (e.g., `spatie/laravel-feature-flags`) to enable Grease only for specific routes or models. Start with non-critical endpoints (e.g., `/api/v1/products`) and monitor for regressions before full adoption.
Does Grease support GraphQL or real-time systems like Livewire?
Grease is less ideal for GraphQL (e.g., Laravel GraphQL resolvers) or real-time systems (WebSockets/Livewire) due to hydration conflicts. Test thoroughly if your app relies on these—optimizations may not apply or could introduce edge cases.
What if a Grease optimization conflicts with a custom Eloquent macro?
Grease prioritizes safety and will skip optimizations that detect macro/global scope conflicts. Log warnings via `Grease::getSkippedOptimizations()` to identify affected queries. Mitigate by excluding specific models or adjusting macros.
How do I handle production rollouts if Grease causes unexpected issues?
Roll out in phases: Start with low-traffic models, then high-traffic endpoints. Use canary releases (e.g., 10% of traffic) and monitor error rates with Sentry or Laravel’s exception logging. Always have a fallback plan to disable Grease via config.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
gmostafa/php-graphql-client
xeviant/paystack
snowsoft/faker
meditationsteps/blogetc
animalyoung/laravel-influxdb
onix-solutions/sms-telera
lonely-lights/prosetta
oxygen/data
oxygen/core
jengo/base
xiloryx/log-collector
a21ns1g4ts/filament-stripe
la-php/laravel-admin
artisan-build/community-prompts
vleroy/smart
ayles-software/laravel-australian-public-holidays
cboxdk/laravel-id-spatie
cboxdk/laravel-id-billing
cboxdk/laravel-id-billing-bridge
simple-as-fuck/php-performance-log