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

Mirror Laravel Package

franbarbalopez/mirror

Mirror is a Laravel package for syncing local or staging databases with production. It provides Artisan commands to export, anonymize, and import data so you can develop and test against realistic data safely without manual dumps.

View on GitHub
Deep Wiki
Context7

Getting Started

  1. Install the package with Composer; Laravel's package discovery registers the service provider automatically:
    composer require franbarbalopez/mirror
    
  2. Publish the configuration and review it before enabling anything:
    php artisan vendor:publish --tag="mirror-config"
    
  3. Look first at config/mirror.php (enable flag, driver/connection options) and at the package README's quick-start example. Then inspect the service provider's boot() method — as of v2.0.1 it deliberately does not touch the session, so anything session-dependent is resolved later in the request lifecycle.
  4. First use case: enable Mirror in a local or staging environment via your .env, exercise a single request (or command, depending on the driver), and confirm the mirrored output/record. Keep it disabled by default in production until you have verified the configuration.

Implementation Patterns

  • Environment-driven configuration. Keep the enable flag and driver selection in config/mirror.php reading from env(), then toggle per environment. This is the normal day-to-day workflow: on locally/staging, off in production.
  • Middleware/request-time resolution. Because the package no longer inspects the session during boot, session-aware decisions (per-user toggles, tenant selection, feature flags) belong in middleware or a listener that runs after the session middleware, not in configuration.
  • Facade/container usage in application code. Resolve the package's manager or facade inside controllers, jobs, or listeners rather than at provider boot. This keeps behaviour predictable under Octane, queue workers, and artisan commands.
  • Testing. Use the package's fake/swap mechanism (or bind a test double into the container) in feature tests so mirroring doesn't hit real destinations. Assert on the mirror call rather than on side effects.
  • Queue and console integration. If mirroring is triggered from jobs or commands, explicitly guard for the absence of a request/session and pass any user context into the job payload rather than relying on ambient session state.
  • Gradual rollout. Wrap the mirror call behind your own feature flag or a dedicated middleware group so you can enable it for one route or one tenant at a time.

Gotchas and Tips

  • v2.0.1 behaviour change. The package no longer reads the session while booting. If you previously relied (even accidentally) on session values being available during provider boot — for example, a config value derived from the logged-in user — move that resolution into middleware, a request macro, or a listener. On the plus side, this removes boot-time failures in console commands, queue workers, and stateless/API requests where no session exists.
  • Config caching. Run php artisan config:clear after changing mirror settings; env() calls outside config files return null once config is cached.
  • Long-running processes. Under Octane or queue workers the provider boots once. Never capture request or session state in singletons; resolve per-request.
  • Missing session in non-HTTP contexts. Any custom extension that assumed a session should explicitly check app()->runningInConsole() or that a request/session is bound before reading it.
  • Debugging. Confirm the provider is discovered (php artisan about), verify the effective config with php artisan tinker or a dump of config('mirror'), and check logs for the driver in use. Temporarily raising the package's log level is usually faster than stepping through middleware.
  • Extension points. Prefer binding a custom driver/implementation through the container or the published config over editing vendor files; keep your overrides in a dedicated service provider so package upgrades remain painless.
  • Upgrade note. v2.0.1 is a patch release and should be a drop-in upgrade from v2.0, but re-test any code that read session data during boot.
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.
elsayed85/laravel-api-exceptions
ouhssini/laravel-demo-mode
daworks/ncloud-outbound-mailer-driver
gp247/cms
ignibyte/aic-gates
nexa-merchant/blog
novasa/laravel-language-center
opencage/geocode
adolfoholzer/parameters
livenetworks/ln-starter
shitoudev/permissionmanager
johannesclimacus/laravel-tui
hocvt/seotools
vitalybaev/sypexgeo
amphibee/themosis-ignition
gito-me/fast-excel
frankyso/laravel-ipaymu
geolize-studio/laravel-chile
boomerangui/chat
cgv/localized-resource