{"id":16466865,"url":"https://github.com/1970mr/laravel-redirector","last_synced_at":"2026-04-25T22:32:37.847Z","repository":{"id":251968657,"uuid":"838305557","full_name":"1970Mr/laravel-redirector","owner":"1970Mr","description":"A Laravel package for managing URL redirects easily and efficiently.","archived":false,"fork":false,"pushed_at":"2024-08-10T17:32:19.000Z","size":63,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-06-08T00:42:01.927Z","etag":null,"topics":["laravel","laravel-package","laravel-redirector","management","package","redirect","redirection","redirector","redirects","redirects-management","route","routing","testing","url"],"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/1970Mr.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-08-05T11:23:21.000Z","updated_at":"2024-08-10T17:30:07.000Z","dependencies_parsed_at":"2025-02-12T15:44:12.030Z","dependency_job_id":"66412c0d-b6f0-4000-b4d7-f0a085a3b7e6","html_url":"https://github.com/1970Mr/laravel-redirector","commit_stats":null,"previous_names":["1970mr/laravel-redirector"],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/1970Mr/laravel-redirector","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/1970Mr%2Flaravel-redirector","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/1970Mr%2Flaravel-redirector/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/1970Mr%2Flaravel-redirector/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/1970Mr%2Flaravel-redirector/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/1970Mr","download_url":"https://codeload.github.com/1970Mr/laravel-redirector/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/1970Mr%2Flaravel-redirector/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32279654,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-25T18:29:39.964Z","status":"ssl_error","status_checked_at":"2026-04-25T18:29:32.149Z","response_time":59,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["laravel","laravel-package","laravel-redirector","management","package","redirect","redirection","redirector","redirects","redirects-management","route","routing","testing","url"],"created_at":"2024-10-11T11:45:03.052Z","updated_at":"2026-04-25T22:32:37.832Z","avatar_url":"https://github.com/1970Mr.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Laravel Redirector\n\nA Laravel package for managing URL redirects easily and efficiently.\n\n## Table of Contents\n\n- [Installation](#installation)\n- [Configuration](#configuration)\n- [Usage](#usage)\n    - [Middleware](#middleware)\n    - [Artisan Commands](#artisan-commands)\n    - [Controller and Views](#controller-and-views)\n    - [Custom Implementation](#custom-implementation)\n- [Caching](#caching)\n- [Testing](#testing)\n- [License](#license)\n\n## Installation\n\nYou can install the package via Composer:\n\n```bash\ncomposer require 1970mr/laravel-redirector\n```\n\nNext, you need to publish the migration and the config file:\n\n```bash\nphp artisan vendor:publish --provider=\"Mr1970\\LaravelRedirector\\RedirectorServiceProvider\"\n```\n\nRun the migrations to create the necessary database table:\n\n```bash\nphp artisan migrate\n```\n\n## Configuration\n\nThe package provides a configuration file where you can manage various settings, including caching methods and TTL (Time-To-Live). These settings allow you to optimize the performance and scalability of your redirects. Refer to the `config/redirector.php` file for more details.\n\n## Usage\n\n### Middleware\n\nTo use the redirect middleware, you can apply it to specific routes, groups of routes, or add it globally to the HTTP kernel middleware stack.\n\n#### Specific Routes\n\n```php\nuse Mr1970\\LaravelRedirector\\Middlewares\\HandleRedirects;\n\nRoute::middleware([HandleRedirects::class])-\u003egroup(function () {\n    // Your routes here\n});\n```\n\n#### Global Middleware\n\nIn Laravel 11, you can add middleware globally in your `bootstrap/app.php` file:\n\n```php\n-\u003ewithMiddleware(function (Middleware $middleware) {\n     $middleware-\u003eappend(\\Mr1970\\LaravelRedirector\\Middlewares\\HandleRedirects::class);\n})\n```\n\n#### Alias Middleware\n\nYou can use the middleware by its alias or by the class name in your routes:\n\n```php\n// Using alias\nRoute::middleware(['redirector'])-\u003egroup(function () {\n    // Your routes here\n});\n\n// Using class name\nRoute::middleware([\\Mr1970\\LaravelRedirector\\Middlewares\\HandleRedirects::class])-\u003egroup(function () {\n    // Your routes here\n});\n```\n\n### Artisan Commands\n\nThe package provides several Artisan commands to manage redirects:\n\n#### Create Redirect\n\nTo create a redirect, you can use the `redirect:create` Artisan command. This command allows you to specify the source URL, destination URL, status code, and whether the redirect is active.\n\n```bash\nphp artisan redirect:create {source_url} {destination_url} {status_code=301} {is_active=1}\n```\n\n##### Examples\n\n1. Redirect from `/old-page` to `/new-page` with a 301 status code and set it as active:\n\n    ```bash\n    php artisan redirect:create /old-page /new-page 301 1\n    ```\n\n2. Redirect from `/specific-page` to `https://google.com` with a 301 status code and set it as active:\n\n    ```bash\n    php artisan redirect:create /specific-page https://google.com 301 1\n    ```\n\n#### Update Redirect\n\nTo update an existing redirect, you can use the `redirect:update` Artisan command:\n\n```bash\nphp artisan redirect:update {source_url} {destination_url} {status_code=301} {is_active=1}\n```\n\n##### Example\n\nUpdate the redirect from `/old-page` to `/new-destination` with a 302 status code and set it as active:\n\n```bash\nphp artisan redirect:update /old-page /new-destination 302 1\n```\n\n#### Delete Redirect\n\nTo delete a redirect, use the `redirect:delete` Artisan command:\n\n```bash\nphp artisan redirect:delete {source_url}\n```\n\n##### Example\n\nDelete the redirect from `/old-page`:\n\n```bash\nphp artisan redirect:delete /old-page\n```\n\n#### List Redirects\n\nTo list all configured redirects, use the `redirect:list` Artisan command:\n\n```bash\nphp artisan redirect:list\n```\n\n### Controller and Views\n\nYou can also set up a more customizable CRUD interface for redirects using controllers, requests, routes, and views. The package provides a command to scaffold these components:\n\n```bash\nphp artisan redirector:install\n```\n\nThis command will install the necessary controllers, requests, routes, and views for managing redirects through a web interface.\n\n### Custom Implementation\n\nAdditionally, you can use the Redirect model directly to create, update, or delete redirects within your application code as needed. This approach allows for complete customization of how and where redirects are managed.\n\n## Caching\n\nThe package supports two caching methods:\n\n- **Full List**: All active redirects are cached as a single collection. This method is efficient for a small number of redirects but may become inefficient as the number of redirects grows. Any create, update, or delete operation will reset the entire list cache.\n- **Single**: Each redirect is cached individually. This method scales better with a large number of redirects but may result in more cache operations. Only the specific cached item is reset during create, update, or delete operations.\n\nYou can configure the caching method and TTL in the `config/redirector.php` file to suit your application's needs.\n\n## Testing\n\nTo run the tests for the package, use the following command:\n\n```bash\ncomposer test\n```\n\n## License\n\nThe MIT License (MIT). Please see [License File](LICENSE.md) for more information.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F1970mr%2Flaravel-redirector","html_url":"https://awesome.ecosyste.ms/projects/github.com%2F1970mr%2Flaravel-redirector","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F1970mr%2Flaravel-redirector/lists"}