{"id":15355748,"url":"https://github.com/chrisrhymes/link-checker","last_synced_at":"2025-07-02T07:07:19.281Z","repository":{"id":59486043,"uuid":"537542486","full_name":"chrisrhymes/link-checker","owner":"chrisrhymes","description":"A Laravel package that will check for broken links within HTML for a specified model's fields.","archived":false,"fork":false,"pushed_at":"2025-06-03T10:38:21.000Z","size":54,"stargazers_count":14,"open_issues_count":2,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-06-03T22:16:47.344Z","etag":null,"topics":["broken-link-finder","broken-links","eloquent","laravel","laravel-package","links","php"],"latest_commit_sha":null,"homepage":"https://packagist.org/packages/chrisrhymes/link-checker","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/chrisrhymes.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null},"funding":{"github":["chrisrhymes"],"patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"lfx_crowdfunding":null,"custom":null}},"created_at":"2022-09-16T16:46:01.000Z","updated_at":"2025-04-26T11:28:18.000Z","dependencies_parsed_at":"2024-01-23T10:08:38.603Z","dependency_job_id":null,"html_url":"https://github.com/chrisrhymes/link-checker","commit_stats":{"total_commits":16,"total_committers":2,"mean_commits":8.0,"dds":0.25,"last_synced_commit":"08736360685e12635199f781ff73677f093ad763"},"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"purl":"pkg:github/chrisrhymes/link-checker","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chrisrhymes%2Flink-checker","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chrisrhymes%2Flink-checker/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chrisrhymes%2Flink-checker/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chrisrhymes%2Flink-checker/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/chrisrhymes","download_url":"https://codeload.github.com/chrisrhymes/link-checker/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chrisrhymes%2Flink-checker/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263091027,"owners_count":23412344,"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":["broken-link-finder","broken-links","eloquent","laravel","laravel-package","links","php"],"created_at":"2024-10-01T12:25:25.894Z","updated_at":"2025-07-02T07:07:19.240Z","avatar_url":"https://github.com/chrisrhymes.png","language":"PHP","funding_links":["https://github.com/sponsors/chrisrhymes"],"categories":[],"sub_categories":[],"readme":"# Link Checker for Laravel\n\nA package that will check for broken links in the specified model's fields. It will check both URL fields and fields containing HTML.\n\n![Downloads](https://img.shields.io/packagist/dt/chrisrhymes/link-checker.svg)\n![Downloads](https://img.shields.io/github/stars/chrisrhymes/link-checker.svg)\n\n## Contents\n\n- [Getting Started](#getting-started)\n- [Usage](#usage)\n  - [Relative links](#relative-links)\n- [Rate Limiting](#rate-limiting)\n- [User Agent](#user-agent)\n- [Verify SSL](#verify-ssl)\n- [Tests](#tests)\n\n## Getting Started\n\n```bash\ncomposer require chrisrhymes/link-checker\n```\n\n### Migrate the database\n\n```bash\nphp artisan migrate\n```\n\n### Add the Trait to your models\n\nAdd the HasBrokenLinks trait to your model\n\n```php\n\u003c?php\n\nnamespace App\\Models;\n\nuse ChrisRhymes\\LinkChecker\\Traits\\HasBrokenLinks;\nuse Illuminate\\Database\\Eloquent\\Model;\n\nclass Post extends Model\n{\n    use HasFactory, HasBrokenLinks;\n}\n```\n\n### Publish the config (optional)\n\nBy default, the timeout for link checks is set to 10 seconds. There are also settings for the rate limiting.\n\nIf you wish to change this then publish the configuration file and update the values.\n\n```bash\nphp artisan vendor:publish --provider=\"ChrisRhymes\\LinkChecker\\ServiceProvider\"\n```\n\n## Usage\n\nThen you can check if the model has broken links in the specified field(s).\n\n```php\nuse ChrisRhymes\\LinkChecker\\Jobs\\CheckModelForBrokenLinks;\nuse ChrisRhymes\\LinkChecker\\Facades\\LinkChecker;\n\n$post = Post::first();\n\n// Dispatch the job directly\nCheckModelForBrokenLinks::dispatch($post, ['content', 'url']);\n\n// Or using the facade\nLinkChecker::checkForBrokenLinks($post, ['content', 'url']);\n```\n\nThis will queue a job to get the links from the model, which will then queue a job to check each link it finds.\n\nThe job will record an entry in the database for broken links with an empty url, but will skip testing mailto or tel links.\n\nYou will then need to run the queue to run the checks.\n\n```bash\nphp artisan queue:work\n```\n\nIt checks the link using the Laravel Http client `Http::get($link)-\u003efailed()` and if it fails it is determined to be a broken link.\n\nAny broken links will be stored in the broken_links table, with a polymorphic relationship back to the original model.\n\nIf an exception is thrown, such as a timeout, then an exception_message will also be recorded in the broken_links table.\n\n```php\n$post = Post::first();\n\n$post-\u003ebrokenLinks; // A collection of broken links for the model\n\n$post-\u003ebrokenLinks[0]-\u003ebroken_link; // The link that is broken\n$post-\u003ebrokenLinks[0]-\u003eexception_message; // The optional exception message\n```\n\n### Relative links\n\nIf you have relative links within a html field in your model (that don't begin with 'http'), then you can pass a 3rd parameter as the base. The CheckModelForBrokenLinks job will prepend the base to the relative url before it is checked.\n\nIf your relative links don't begin with `/`, then ensure your base parameter has a trailing slash, `'http://example.com/'`.\n\n```php\nuse ChrisRhymes\\LinkChecker\\Jobs\\CheckModelForBrokenLinks;\nuse ChrisRhymes\\LinkChecker\\Facades\\LinkChecker;\n\n$post = Post::first();\n\n// Dispatch the job directly\nCheckModelForBrokenLinks::dispatch($post, ['content', 'url'], 'http://example.com');\n\n// Or using the facade\nLinkChecker::checkForBrokenLinks($post, ['content', 'url'], 'http://example.com');\n```\n\n## Rate Limiting\n\nIn order to reduce the amount of requests sent to a domain at a time, this package has rate limiting enabled.\n\nThe configuration file allows you to set the `rate_limit` to set how many requests can be sent to a single domain within a minute. The default is set to 5, so adjust as required for your circumstances.\n\nThe configuration file also allows you to set the `retry_until` so the job will be retried until the time limit (in munites) is reached.\n\n## User Agent\n\nTo set a custom user agent for requests sent by the link checker, set the `user_agent` in the configuration file. For example `'user_agent' =\u003e 'my-user-agent',`\n\nThe default value is `link-checker`.\n\n## Verify SSL\n\nTo disable verifying the SSL certificate of the link you are checking, [publish the package configuration](#publish-the-config-optional) and then set `'verify' =\u003e false,`.\n\nThis uses the HTTP client withOptions() to set the [verify request option in Guzzle](https://docs.guzzlephp.org/en/stable/request-options.html#verify).\n\n## Tests\n\nThe tests are built with [Pest](https://pestphp.com/).\n\nRun the tests using either of the below commands.\n\n```bash\nvendor/bin/pest\n\n// Or\n\ncomposer test\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchrisrhymes%2Flink-checker","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchrisrhymes%2Flink-checker","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchrisrhymes%2Flink-checker/lists"}