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

Audit Bundle Laravel Package

rigosv/audit-bundle

An audit bundle for Laravel that records model and application activity for traceability. Logs changes with user context so you can review who did what and when, supporting compliance and debugging across your PHP projects.

View on GitHub
Deep Wiki
Context7

Getting Started

v0.1.9 is a small, additive release ("Session id added") with no deprecations or breaking changes signalled, so upgrading from v0.1.8 should be a no-op beyond a composer update. Because the package is still on a 0.x line, treat minor bumps as potentially breaking by convention and pin explicitly: "vendor/package": "^0.1.9".

Minimal setup:

  1. composer require vendor/package:^0.1.9
  2. Confirm the service provider is picked up by package discovery (php artisan about or check bootstrap/cache/packages.php). If the package is not discovery-friendly, register the provider manually in bootstrap/providers.php.
  3. Publish and review assets before touching code:
    php artisan vendor:publish --provider="Vendor\\Package\\PackageServiceProvider"
    
    The two things worth reading first are the published config file (to see whether session id capture is opt-in) and any migration (to confirm the new column is nullable on existing tables).
  4. Clear caches after publish: php artisan config:clear && php artisan optimize:clear.

Your first use case should be the smallest possible: hit a stateful web route, then inspect the record/log entry the package produces and confirm a non-null session id. If it is null on a route you expect to be stateful, the problem is almost always middleware ordering or a stateless route — see below.

Implementation Patterns

Verify middleware position. Session id only exists after Laravel's StartSession middleware has run. If the package ships its own middleware, place it after the web group (or explicitly after StartSession) in bootstrap/app.php:

->withMiddleware(function (Middleware $middleware) {
    $middleware->web(append: [
        \Vendor\Package\Middleware\CaptureContext::class,
    ]);
})

Correlate logs with the session id. The main day-to-day value of this release is traceability. Push the session id into log context once per request (a Monolog processor or a small middleware) so every line in a request's lifetime is greppable:

Log::withContext([
    'session_id' => $request->hasSession() ? $request->session()->getId() : null,
]);

Guard for session-less contexts. Console commands, queued jobs, health checks, and api-guarded routes have no session. Resolve the value defensively rather than assuming a string:

$sessionId = $request->hasSession() ? $request->session()->getId() : null;

Pass it forward explicitly. When dispatching a job from a request, copy the session id onto the job payload if you need end-to-end tracing; the queue worker does not inherit session state.

Test it. Feature tests using $this->actingAs($user) or $this->withSession([...]) will produce a session id; tests hitting stateless endpoints will not. Assert both cases so the null path stays covered:

$response->assertSessionHasNoErrors();
$this->assertNotNull(session()->getId());

Prefer the package's resolver over reaching into the session directly. If the package exposes a config-driven resolver or a container binding for the current context, bind a fake in tests rather than mocking Session — it keeps test setup aligned with how production resolves the value.

Gotchas and Tips

  • Session id changes mid-request on login. Auth::login() and $request->session()->regenerate() mint a new id. Capture the value late (in a terminating middleware or Terminating/JobProcessed-style hook) if you need the id that is actually persisted to the cookie.
  • session()->getId() before StartSession is a different id (or throws on a store with no started session). Middleware order is the number one cause of "session id is null/empty" reports.
  • Stateless routes and api guards never have a session. Don't make the new column non-nullable, and don't let downstream code assume a string.
  • Octane and long-lived workers. Never cache the session id on a singleton or in a static property — it belongs to the request lifecycle and will leak across requests.
  • Testing driver quirks. The array session driver does not persist across requests; withoutMiddleware(StartSession::class) in a test will silently remove the session id and produce confusing assertions.
  • Existing data. If the release adds a column, check the migration for nullability and default. On large tables, prefer a nullable column plus a background backfill over a blocking ALTER with a default.
  • Config caching in deployment. After changing package config, php artisan config:cache must be re-run or the old values persist — a very common cause of "the feature is enabled locally but not in staging".
  • Debugging checklist: php artisan route:list -v (middleware stack), php artisan tinker with session()->getId(), and php artisan config:show vendor-package to confirm the published config is actually loaded.
  • Extension points to watch as the package matures. The publishable config, any swappable model/repository binding, and published migrations are the seams you should customise through — avoid editing vendor files, since this package is young enough that 0.x releases may move internals.
  • Watch the changelog for 0.2.0. With an active 0.x line, the smallest-looking release can precede a rename of the session id accessor; a thin internal wrapper around the package's API will keep that upgrade cheap.
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.
coleus/frame
thtg88/journalism
filagora/filagora-ai-forums
rlacerda83/query-parser
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