spatie/laravel-sql-commenter
Adds sqlcommenter-style comments to Laravel database queries, embedding context like controller and action. Makes it easy to trace slow or problematic SQL back to the exact code path, and works with tools like PlanetScale Query Insights.
user_id=123/*controller='AdminController',action='delete'*/) to meet regulatory requirements (e.g., GDPR data access logs)./*tenant='acme',feature='new_ui'*/) to isolate performance issues in segmented environments.Adopt if:
Look elsewhere if:
*"This lightweight package adds ‘breadcrumbs’ to every SQL query in our Laravel app—tagging them with the controller/action that generated them. For example, a slow users table query will now include /*controller='UsersController',action='index'*/ in logs. This directly supports our goals to:
*"This is a zero-config way to inject SQL comments into all Laravel queries, using the sqlcommenter standard. Key benefits:
/*tenant='X',feature='Y'*/) via service provider.composer.json, configure in AppServiceProvider, and validate in staging. Pair with Laravel Telescope for immediate visibility.
Alternatives: Custom middleware (higher maintenance) or no solution (debugging pain)."*How can I help you explore Laravel packages today?