{"id":15561138,"url":"https://github.com/yorcreative/laravel-query-watcher","last_synced_at":"2025-04-23T21:48:47.360Z","repository":{"id":57133888,"uuid":"526995499","full_name":"YorCreative/Laravel-Query-Watcher","owner":"YorCreative","description":"A Laravel package that provides configurable application query capturing \u0026 monitoring.","archived":false,"fork":false,"pushed_at":"2022-09-08T23:25:46.000Z","size":272,"stargazers_count":37,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-23T21:48:36.134Z","etag":null,"topics":["capture-queries","hacktoberfest","hacktoberfest2022","laravel","laravel-framework","laravel-package","php","queries","query-capture","query-watcher","slow-query","slow-query-monitoring","sql","sql-monitoring"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/YorCreative.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-08-20T17:31:01.000Z","updated_at":"2023-04-11T22:46:21.000Z","dependencies_parsed_at":"2022-09-03T20:34:26.143Z","dependency_job_id":null,"html_url":"https://github.com/YorCreative/Laravel-Query-Watcher","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/YorCreative%2FLaravel-Query-Watcher","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/YorCreative%2FLaravel-Query-Watcher/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/YorCreative%2FLaravel-Query-Watcher/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/YorCreative%2FLaravel-Query-Watcher/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/YorCreative","download_url":"https://codeload.github.com/YorCreative/Laravel-Query-Watcher/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250522294,"owners_count":21444510,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["capture-queries","hacktoberfest","hacktoberfest2022","laravel","laravel-framework","laravel-package","php","queries","query-capture","query-watcher","slow-query","slow-query-monitoring","sql","sql-monitoring"],"created_at":"2024-10-02T16:05:43.229Z","updated_at":"2025-04-23T21:48:47.342Z","avatar_url":"https://github.com/YorCreative.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cbr /\u003e\n\u003cbr /\u003e\n\n\u003cdiv align=\"center\"\u003e\n  \u003ca href=\"https://github.com/YorCreative\"\u003e\n    \u003cimg src=\"content/logo.png\" alt=\"Logo\" width=\"128\" height=\"128\"\u003e\n  \u003c/a\u003e\n\u003c/div\u003e\n\n\u003ch3 align=\"center\"\u003eLaravel Query Watcher\u003c/h3\u003e\n\n\u003cdiv align=\"center\"\u003e\n\u003ca href=\"https://github.com/YorCreative/Laravel-Query-Watcher/stargazers\"\u003e\u003cimg alt=\"GitHub stars\" src=\"https://img.shields.io/github/stars/YorCreative/Laravel-Query-Watcher\"\u003e\u003c/a\u003e\n\u003ca href=\"https://github.com/YorCreative/Laravel-Query-Watcher/issues\"\u003e\u003cimg alt=\"GitHub issues\" src=\"https://img.shields.io/github/issues/YorCreative/Laravel-Query-Watcher\"\u003e\u003c/a\u003e\n\u003ca href=\"https://github.com/YorCreative/Laravel-Query-Watcher/network\"\u003e\u003cimg alt=\"GitHub forks\" src=\"https://img.shields.io/github/forks/YorCreative/Laravel-Query-Watcher\"\u003e\u003c/a\u003e\n\u003ca href=\"https://github.com/YorCreative/Laravel-Query-Watcher/actions/workflows/phpunit.yml\"\u003e\u003cimg alt=\"PHPUnit\" src=\"https://github.com/YorCreative/Laravel-Query-Watcher/actions/workflows/phpunit.yml/badge.svg\"\u003e\u003c/a\u003e\n\u003c/div\u003e\n\n\u003cbr /\u003e\n\n\nA Laravel package that provides configurable application query capturing \u0026 monitoring.\n\n## Installation\n\ninstall the package via composer:\n\n```bash\ncomposer require YorCreative/Laravel-Query-Watcher\n```\n\nPublish the packages assets.\n\n```bash\nphp artisan vendor:publish --provider=\"YorCreative\\QueryWatcher\\QueryWatcherServiceProvider\"\n```\n\n## Usage\n\n### Configuration\n\nAdjust the configuration file to suite your application.\n\n```php\n[\n    // Do you want to capture queries?\n    'enabled' =\u003e env('QUERY_WATCH_ENABLED', true), \n    \n    // Token used for Authenticating Private Broadcast Channel\n    'token' =\u003e env('QUERY_WATCH_TOKEN', 'change_me'), \n    'scope' =\u003e [\n        'time_exceeds_ms' =\u003e [\n            // Do you want to capture everything or only slow queries?\n            'enabled' =\u003e env('QUERY_WATCH_SCOPE_TIME_ENABLED', true), \n            \n            // The number of milliseconds it took to execute the query.\n            'threshold' =\u003e env('QUERY_WATCH_SCOPE_TIME_THRESHOLD', 500), \n        ],\n        'context' =\u003e [\n            'auth_user' =\u003e [\n                // Do you want to know context of the authenticated user when query is captured?\n                'enabled' =\u003e env('QUERY_WATCH_SCOPE_CONTEXT_AUTH_ENABLED', true),\n                 \n                // How long do you want the session_id/authenticated user cached for? \n                // without this cache, your application will infinite loop because it will capture\n                // the user query and loop.\n                // See closed Issue #1 for context.\n                'ttl' =\u003e env('QUERY_WATCH_SCOPE_CONTEXT_AUTH_TTL', 300), \n            ],\n            'trigger' =\u003e [\n                // Do you want to know what triggered the query?\n                // i.e Console command or Request\n                'enabled' =\u003e env('QUERY_WATCH_SCOPE_TRIGGER_ENABLED', true), \n            ],\n        ],\n        'ignorable_tables' =\u003e [\n            // Do you want to capture queries on specific tables?\n            // If you are utilizing the database queue driver, you need to\n            // ignore the jobs table, or you'll potentially get infinite capture loops.\n            'jobs',\n            'failed_jobs'\n        ],\n        'ignorable_statements' =\u003e [\n            // Do you want to ignore specific SQL statements?\n            'create' \n        ]\n    ],\n    'listener' =\u003e [ \n        // Channel notifications are queued\n        // Define what connection to use.\n        'connection' =\u003e 'sync',\n        \n        //  Define what queue to use \n        'queue' =\u003e 'default',\n        \n        // Do you want to delay the notifications at all? \n        'delay' =\u003e null, \n    ],\n    'channels' =\u003e [ // Where to send notifications?\n        'discord' =\u003e [ \n            // Do you want discord webhook notifications?\n            'enabled' =\u003e env('QUERY_WATCH_CHANNEL_DISCORD_ENABLED', false),\n            \n            // Discord Web-hook URL \n            'hook' =\u003e env('DISCORD_HOOK', 'please_fill_me_in'), \n        ],\n        'slack' =\u003e [ \n            // Do you want Slack webhook notifications?\n            'enabled' =\u003e env('QUERY_WATCH_CHANNEL_SLACK_ENABLED', false),\n            \n            // Slack Web-hook URL\n            'hook' =\u003e env('SLACK_HOOK', 'please_fill_me_in'), \n        ],\n    ]\n]\n```\n\n### Broadcasting\n\nAll captured queries will broadcast on a private channel as the primary monitoring method. The QueryEvent that is\nbroadcasting is using your\napplications [broadcast configuration](https://laravel.com/docs/9.x/broadcasting#configuration).\n\n```php\n    /**\n     * Get the channels the event should broadcast on.\n     *\n     * @return PrivateChannel\n     */\n    public function broadcastOn(): PrivateChannel\n    {\n        return new PrivateChannel('query.event.'. config('querywatcher.token'));\n    }\n\n    /**\n     * @return string\n     */\n    public function broadcastAs(): string\n    {\n        return 'query.event';\n    }\n```\n\n### Slack Notification Channel\n\nTo utilize Slack Notifications, you will need to [create a webhook](https://api.slack.com/messaging/webhooks#create_a_webhook) for one of your Slack Channels. Once you have your\nwebhook url, add the following variable to your .env file.\n\n```dotenv\nSLACK_HOOK=\u003chook\u003e\n```\n\nOnce you have done this, you can enable Slack Notifications in the configuration file.\n\n### Discord Notification Channel\n\nGet a webhook URL from discord in the channel you want to receive your notifications in by\nreading [Discords Introduction to Webhook Article](https://support.discord.com/hc/en-us/articles/228383668-Intro-to-Webhooks)\n. Once you have your webhook url, add the following variable to your `.env` file.\n\n```dotenv\nDISCORD_HOOK=\u003chook\u003e\n```\n\nOnce you have done this, you can enable Discord Notifications in the configuration file.\n\n### Wiki Documentation\n\n- [Notification Channels Wiki](https://github.com/YorCreative/Laravel-Query-Watcher/wiki/Notification-Channels)\n- [Screenshots](https://github.com/YorCreative/Laravel-Query-Watcher/wiki/Screenshots)\n\n## Testing\n\n```bash\ncomposer test\n```\n\n## Credits\n\n- [Yorda](https://github.com/yordadev)\n- [All Contributors](../../contributors)\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyorcreative%2Flaravel-query-watcher","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyorcreative%2Flaravel-query-watcher","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyorcreative%2Flaravel-query-watcher/lists"}