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

Laravel Model Self Cache Laravel Package

mixislv/laravel-model-self-cache

A Laravel package that gives Eloquent models self-caching capabilities, letting models cache their own queries and attributes automatically and invalidate cached data on create, update, or delete. Reduces repeated database hits with minimal changes to existing model code.

View on GitHub
Deep Wiki
Context7

Getting Started

  • Confirm your app runs Laravel 6+ before installing. v2.0.0 drops Laravel 5.x support, so Composer will reject installs on older framework versions.
  • Install with composer require <vendor>/<package>:^2.0.
  • Publish any package config if the package provides it:
    php artisan vendor:publish --provider="Vendor\Package\PackageServiceProvider"
    
  • Look first at:
    • config/<package>.php for runtime options
    • the package service provider for bindings, aliases, and publishable assets
    • the README upgrade section and changelog for v1 → v2 differences
  • First use case: resolve the package’s primary service from the container and run the simplest documented operation, e.g.:
    $service = app(\Vendor\Package\Contracts\Service::class);
    $result = $service->handle($input);
    
  • If the package exposes a facade, prefer dependency injection in application code and reserve the facade for quick scripts, Blade, and legacy code.

Implementation Patterns

  • Constructor injection over facades: inject the package contract or service into controllers, jobs, listeners, and actions. This keeps tests explicit and avoids hidden container lookups.
  • Config-first setup: keep package behavior in config/<package>.php and environment variables rather than scattering options across code. Use config:cache in deployment pipelines and verify the package reads config lazily, not in a way that breaks cached config.
  • Thin integration layer: wrap package calls in your own application service or action when the package is used in more than one place. This limits blast radius if the package API changes again in v2.x.
  • Queue and event integration: if the package dispatches events, listens to webhooks, or performs slow work, route that work through Laravel queues. Test with Queue::fake() and Event::fake() where appropriate.
  • Testing pattern:
    public function test_package_operation(): void
    {
        $this->app->instance(\Vendor\Package\Contracts\Service::class, $fake = Mockery::mock(...));
    
        $fake->shouldReceive('handle')->once()->andReturn('ok');
    
        $this->post('/endpoint')->assertOk();
    }
    
  • Upgrade workflow for v2:
    1. Bump application/framework dependencies to Laravel 6+.
    2. Update the package constraint to ^2.0.
    3. Run composer update <vendor>/<package> --with-dependencies.
    4. Re-publish config only if the changelog says the config shape changed; otherwise diff published config against the package default.
    5. Run the package’s tests plus your own integration tests, especially around service provider boot order and config caching.
  • CI matrix: test against the Laravel versions you actually deploy. At minimum, include Laravel 6, 7, 8, etc., matching the package’s declared illuminate/support constraint.
  • Version pinning: pin ^2.0 or a narrower range in production. Avoid * so future major releases do not silently change behavior.

Gotchas and Tips

  • Laravel 5.x is unsupported in v2.0.0. This is the main breaking change. If you are still on Laravel 5.x, stay on the latest v1 release or upgrade the framework first.
  • Composer conflicts are expected on Laravel 5.x. If composer require fails with conflicting illuminate/* constraints, check the package’s composer.json and your app’s framework version before debugging application code.
  • Do not assume v1 config is valid in v2. Even when release notes are short, major versions often include config key renames, removed options, or changed defaults. Diff published config and check for removed keys.
  • Clear caches after upgrade:
    php artisan config:clear
    php artisan cache:clear
    php artisan route:clear
    php artisan view:clear
    
    Then rebuild with config:cache and route:cache in the same way production does.
  • Watch service provider boot order. If the package depends on another package or on app bindings, register it consistently and avoid resolving its services during register() unless documented.
  • Extension points: prefer the package’s published config, container bindings, events, and interfaces over subclassing internal classes. Major versions are more likely to preserve contracts than concrete internals.
  • Debugging tip: when behavior differs between local and production, compare php artisan about, composer show <vendor>/<package>, and cached config. Laravel 5.x vs 6+ differences often surface as missing bindings or changed framework behavior.
  • Deprecation strategy: treat v2.0.0 as the new baseline. If you maintain shared packages or internal apps, update their Composer constraints and CI matrices now so future v2.x releases do not block upgrades.
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.
socialdept/atp-orm
cboxdk/laravel-assistant-client
socialdept/atp-resolver
socialdept/tenant-domains
tautvydasr/blade-class-names
socialdept/color-scales
maherelgamil/controller
coleus/widgets
coleus/table
coleus/users
coleus/music
coleus/health
coleus/calendar
coleus/notes
coleus/support
coleus/settings
coleus/apps
seampact/laravel
emmyconceptng/laravel-ng-postcode
jjsquady/round-robin