{"id":14975319,"url":"https://github.com/sirodiaz/laravel-redirection","last_synced_at":"2025-04-05T00:07:36.595Z","repository":{"id":40451321,"uuid":"414126024","full_name":"SiroDiaz/laravel-redirection","owner":"SiroDiaz","description":"Laravel 8, 9, 10 and 11 package to manage URL redirections inside your Laravel application using different data sources. It allows a better SEO support for your Laravel site.","archived":false,"fork":false,"pushed_at":"2024-10-22T12:21:15.000Z","size":62,"stargazers_count":61,"open_issues_count":3,"forks_count":4,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-05T00:07:31.381Z","etag":null,"topics":["database","laravel","laravel-10","laravel-10-package","laravel-8","laravel-8-package","laravel-9","laravel-9-package","laravel-framework","laravel-package","laravel-redirect","php","seo","seo-optimization","url","url-redirect","url-redirection","url-redirections"],"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/SiroDiaz.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":".github/CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":".github/SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"SiroDiaz"}},"created_at":"2021-10-06T08:14:10.000Z","updated_at":"2025-01-28T10:54:12.000Z","dependencies_parsed_at":"2024-02-10T14:24:30.186Z","dependency_job_id":"70ab5db7-cb3c-4cb5-8b64-c0ab2d1055ea","html_url":"https://github.com/SiroDiaz/laravel-redirection","commit_stats":{"total_commits":45,"total_committers":4,"mean_commits":11.25,"dds":0.2666666666666667,"last_synced_commit":"6604afc20b6494982900b6d9a4653af370e08c25"},"previous_names":[],"tags_count":7,"template":false,"template_full_name":"spatie/package-skeleton-laravel","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SiroDiaz%2Flaravel-redirection","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SiroDiaz%2Flaravel-redirection/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SiroDiaz%2Flaravel-redirection/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SiroDiaz%2Flaravel-redirection/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SiroDiaz","download_url":"https://codeload.github.com/SiroDiaz/laravel-redirection/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247266563,"owners_count":20910836,"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":["database","laravel","laravel-10","laravel-10-package","laravel-8","laravel-8-package","laravel-9","laravel-9-package","laravel-framework","laravel-package","laravel-redirect","php","seo","seo-optimization","url","url-redirect","url-redirection","url-redirections"],"created_at":"2024-09-24T13:51:51.959Z","updated_at":"2025-04-05T00:07:36.570Z","avatar_url":"https://github.com/SiroDiaz.png","language":"PHP","funding_links":["https://github.com/sponsors/SiroDiaz"],"categories":[],"sub_categories":[],"readme":"# Laravel package for manage your URL redirects in database or other sources to get better SEO results\n\n[![Latest Version on Packagist](https://img.shields.io/packagist/v/sirodiaz/laravel-redirection.svg?style=flat-square)](https://packagist.org/packages/SiroDiaz/laravel-redirection)\n[![run-tests](https://github.com/SiroDiaz/laravel-redirection/actions/workflows/run-tests.yml/badge.svg)](https://github.com/SiroDiaz/laravel-redirection/actions/workflows/run-tests.yml)\n[![Check \u0026 fix styling](https://github.com/SiroDiaz/laravel-redirection/actions/workflows/php-cs-fixer.yml/badge.svg?branch=main)](https://github.com/SiroDiaz/laravel-redirection/actions/workflows/php-cs-fixer.yml)\n[![Total Downloads](https://img.shields.io/packagist/dt/SiroDiaz/laravel-redirection.svg?style=flat-square)](https://packagist.org/packages/SiroDiaz/laravel-redirection)\n\n## Requirements\n\nYou need PHP 8.0 or higher. It is tested and designed for Laravel 9 and 10.\nThis package will receive updates for future Laravel versions. Previous Laravel versions\nare not contemplated so use [Neurony/laravel-redirects](https://github.com/Neurony/laravel-redirects) package for\nolder Laravel versions.\n\n## Installation\n\nYou can install the package via composer:\n\n```bash\ncomposer require SiroDiaz/laravel-redirection\n```\n\nYou can publish and run the migrations with:\n\n```bash\nphp artisan vendor:publish --provider=\"SiroDiaz\\Redirection\\RedirectionServiceProvider\" --tag=\"redirection-migrations\"\nphp artisan migrate\n```\n\nYou can publish the config file with:\n```bash\nphp artisan vendor:publish --provider=\"SiroDiaz\\Redirection\\RedirectionServiceProvider\" --tag=\"redirection-config\"\n```\n\nThis is the contents of the published config file:\n\n```php\n\u003c?php\n\nreturn [\n    /*\n    |--------------------------------------------------------------------------\n    | Status codes valid for redirections\n    |--------------------------------------------------------------------------\n    |\n    | The redirect statuses that you will use in your application.\n    | By default, the \"301\", \"302\" and \"307\" are defined.\n    |\n    */\n    'statuses' =\u003e [\n        301 =\u003e 'Permanent (301)',\n        302 =\u003e 'Normal (302)',\n        307 =\u003e 'Temporary (307)',\n    ],\n\n    /*\n    |--------------------------------------------------------------------------\n    | Default Redirect status code (in case of not defined)\n    |--------------------------------------------------------------------------\n    |\n    | Status code used by default to redirect from an old URL to a new mapped\n    | URL.\n    |\n    */\n    'default_status_code' =\u003e (int)env('REDIRECT_DEFAULT_STATUS', 301),\n\n    /*\n    |--------------------------------------------------------------------------\n    | Case sensitivity\n    |--------------------------------------------------------------------------\n    |\n    | Whether to match URLs case sensitively or not.\n    | Default to false because most URLs are not case sensitive.\n    |\n    */\n    'case-sensitive' =\u003e (bool) env('REDIRECT_CASE_SENSITIVE', false),\n\n    /*\n    |--------------------------------------------------------------------------\n    | Redirect Driver\n    |--------------------------------------------------------------------------\n    |\n    | Here you may specify the default redirect driver that you want to use.\n    | The \"config\" driver is used by default when you want to code faster.\n    | Consider database driver better for admin panel configuration backed by\n    | a relational DB.\n    |\n    */\n    'driver' =\u003e env('REDIRECT_DRIVER', 'config'),\n\n    /*\n    |--------------------------------------------------------------------------\n    | Array containing all available drivers and its implementations and source\n    |--------------------------------------------------------------------------\n    |\n    | Concrete implementation for the \"redirection model\".\n    | To extend or replace this functionality, change the value below with\n    | your full \"redirection model\" FQN.\n    |\n    | Your class will have to (first option is recommended):\n    | - extend the \"SiroDiaz\\Redirection\\Models\\Redirection\" class\n    | - or at least implement the \"SiroDiaz\\Redirection\\Contracts\\RedirectionModelContract\" interface.\n    |\n    | Regardless of the concrete implementation below, you can still use it like:\n    | - app('redirection.') OR app('\\SiroDiaz\\Redirection\\Contracts\\RedirectionModelContract')\n    | - or you could even use your own class as a direct implementation. For this\n    | case you must extend from \"SiroDiaz\\Redirection\\Models\\Redirection\" model class and\n    | replace in the published config file 'drivers.database.source'.\n    |\n    |\n    */\n    'drivers' =\u003e [\n        'config' =\u003e [\n            'driver' =\u003e SiroDiaz\\Redirection\\Drivers\\FileRedirector::class,\n            'source' =\u003e 'redirection.urls',\n        ],\n        'database' =\u003e [\n            'driver' =\u003e SiroDiaz\\Redirection\\Drivers\\DatabaseRedirector::class,\n            'source' =\u003e SiroDiaz\\Redirection\\Models\\Redirection::class,\n        ],\n    ],\n\n    /*\n    |--------------------------------------------------------------------------\n    | Url list with redirections used for config driver\n    |--------------------------------------------------------------------------\n    |\n    | You can use urls array of two different ways. The simple one uses the\n    | default redirect status code ('redirection.default_status_code').\n    | Example:\n    | 'urls' =\u003e [\n    |   '/old/url' =\u003e '/new/url',\n    |   '/another/old/url' =\u003e '/another/new/url',\n    |   '/url/with?id=123' =\u003e '/url/with/123',\n    | ],\n    |\n    | The second way to write redirect urls in your config/redirection.php\n    | is using associative arrays. You can combine this method with the previous one.\n    | Look at this example:\n    | 'urls' =\u003e [\n    |   '/old/url' =\u003e ['new_url' =\u003e '/new/url', 'status_code' =\u003e 302],\n    |   '/another/old/url' =\u003e '/another/new/url',\n    |   '/url/with?id=123' =\u003e ['new_url' =\u003e '/url/with/123'],\n    | ],\n    |\n    */\n    'urls' =\u003e [],\n\n];\n\n\n```\n\nYou can change and extend the default `SiroDiaz\\Redirection\\Models\\Redirection` model class.\nImage that you want to add some methods or fields. You would need to create a new model class, for example `App\\Models\\Redirect`.\n\nHere is a basic example of how to extend the functionality of the default Redirection model.\nWe want to include support for Laravel BackPack admin panel would be:\n```php\n\u003c?php\n\nnamespace App\\Models;\n\nuse SiroDiaz\\Redirection\\Models\\Redirection as RedirectionBaseModel;\nuse Backpack\\CRUD\\app\\Models\\Traits\\CrudTrait;\n\nclass Redirect extends Redirection\n{\n    use CrudTrait;\n}\n```\n\nFinally, you have to vendor:publish the `sirodiaz/laravel-redirection` config file to change the model\nclass used now.\n\nIf you want to add more status codes for another type of redirect purposes, add them to your config/redirection.php\nconfig file. By default, you have the most common redirections codes: 301, 302 and 307.\n\nEy! **don't forget** to append the middleware `SiroDiaz\\Redirection\\RedirectRequests` to your `app/Http/Kernel.php` file\n\n```php\n// app/Http/Kernel.php\n\n    protected $middleware = [\n        ...\n        \\SiroDiaz\\Redirection\\RedirectRequests::class,\n    ],\n```\n\n## Extending and creating new redirect Drivers\n**TODO**\n\n## Testing this package for contribution\n\n```bash\ncomposer test\n```\n\n## Changelog\n\nPlease see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.\n\n## Contributing\n\nPlease see [CONTRIBUTING](.github/CONTRIBUTING.md) for details.\n\n## Credits\n\n- [SiroDiaz](https://github.com/SiroDiaz)\n- [All Contributors](../../contributors)\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%2Fsirodiaz%2Flaravel-redirection","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsirodiaz%2Flaravel-redirection","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsirodiaz%2Flaravel-redirection/lists"}