adam-dziuk/laravel-agent-cost
Track and monitor the cost of AI agents in your Laravel application. Log usage and spend, gain visibility into token consumption, and keep budgets under control with a simple, framework-native integration.
v1.0.1 adds an opt-in prebuilt dashboard, which changes the recommended first-run path: you no longer need to build a UI before you can see the package working.
php artisan vendor:publish output):
composer require <vendor>/<package>:^1.0.1
php artisan vendor:publish --provider="<Vendor>\<Package>\<Package>ServiceProvider"
config/<package>.php first — this is the source of truth for the release. Look for the dashboard block added in 1.0.1 and flip it on:
'dashboard' => [
'enabled' => env('<PACKAGE>_DASHBOARD_ENABLED', false),
// likely: 'path', 'middleware', 'domain'
],
php artisan config:clear
php artisan route:list | grep -i dashboard
local/staging only, hit the dashboard route, and use it as a read-only sanity check that your data/queue/integrations are wired correctly before writing any custom code.The dashboard is deliberately off by default. Treat "enable it and look" as step one of onboarding, not as a production feature decision.
Environment-scoped enablement. Drive the flag from env rather than hardcoding true. Enable in local and staging, keep it off in production until you've reviewed what it exposes:
// config/<package>.php
'enabled' => env('<PACKAGE>_DASHBOARD_ENABLED', app()->environment(['local', 'staging'])),
Protect it before you ship it. The prebuilt dashboard is a convenience, not an authorization model. Wrap it in your own middleware/gate in the config rather than trusting the default:
'middleware' => ['web', 'auth', 'can:viewAdminPanel'],
If the package exposes a Gate/policy hook, register it in a service provider so the check is testable rather than buried in config.
Use it as a scaffold, then diverge. The fastest path is: enable the dashboard, screenshot what you need, then publish the views (usually --tag=views) and move the parts you care about into your own app. Don't fork the vendor views in place — publish, then edit, so upgrades stay clean.
Pair with the programmatic API. The dashboard is a view over whatever the package exposes. For anything you'll automate (alerts, reports, tests), call the underlying API/service directly and keep the dashboard for humans. This keeps your business logic independent of a UI that's one minor version old.
CI and test guardrails. Add a test asserting the dashboard route is absent (or 403s) under your production-like config, so a stray APP_ENV or copy-pasted .env doesn't expose it:
public function test_dashboard_is_not_reachable_for_guests(): void
{
$this->get('/<dashboard-path>')->assertRedirect('/login');
}
Onboarding lever. Because it's config-only, new team members can see real data on day one without writing a line of code. Document the two-step enable in your README — this is the single highest-value thing v1.0.1 gives you.
enabled in .env does nothing after config:cache. Always php artisan config:clear locally and confirm your deploy pipeline re-runs config:cache after the env is in place.route:list before debugging middleware.web only. Verify against a logged-out session and a low-privilege user before enabling anywhere shared./dashboard) and you already own that route, set a custom path or domain in config rather than renaming your own route.^1.0.1 and read the changelog for 1.0.x patch releases — a dashboard landing in a patch version suggests the maintainers are shipping fast, so pin deliberately.How can I help you explore Laravel packages today?