{"id":19700308,"url":"https://github.com/appstract/laravel-multisite","last_synced_at":"2025-04-05T11:11:03.145Z","repository":{"id":62486415,"uuid":"83036877","full_name":"appstract/laravel-multisite","owner":"appstract","description":"Multiple sites on one codebase","archived":false,"fork":false,"pushed_at":"2019-05-23T09:24:36.000Z","size":30,"stargazers_count":214,"open_issues_count":1,"forks_count":30,"subscribers_count":16,"default_branch":"master","last_synced_at":"2025-03-29T10:09:19.376Z","etag":null,"topics":["laravel","middleware","multisite","package"],"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/appstract.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}},"created_at":"2017-02-24T11:56:18.000Z","updated_at":"2025-02-16T04:29:51.000Z","dependencies_parsed_at":"2022-11-02T10:02:25.855Z","dependency_job_id":null,"html_url":"https://github.com/appstract/laravel-multisite","commit_stats":null,"previous_names":[],"tags_count":17,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/appstract%2Flaravel-multisite","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/appstract%2Flaravel-multisite/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/appstract%2Flaravel-multisite/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/appstract%2Flaravel-multisite/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/appstract","download_url":"https://codeload.github.com/appstract/laravel-multisite/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247325693,"owners_count":20920714,"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":["laravel","middleware","multisite","package"],"created_at":"2024-11-11T21:05:22.889Z","updated_at":"2025-04-05T11:11:03.119Z","avatar_url":"https://github.com/appstract.png","language":"PHP","readme":"# Laravel Multisite\n\n[![Latest Version on Packagist](https://img.shields.io/packagist/v/appstract/laravel-multisite.svg?style=flat-square)](https://packagist.org/packages/appstract/laravel-multisite)\n[![Total Downloads](https://img.shields.io/packagist/dt/appstract/laravel-multisite.svg?style=flat-square)](https://packagist.org/packages/appstract/laravel-multisite)\n[![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](LICENSE.md)\n[![Build Status](https://img.shields.io/travis/appstract/laravel-multisite/master.svg?style=flat-square)](https://travis-ci.org/appstract/laravel-multisite)\n\nWith this package it is possible to build multiple sites/(sub)domains on one codebase.\n\n## Installation\n\nYou can install the package via composer:\n\n```bash\ncomposer require appstract/laravel-multisite\n```\n\n### Config (hosts, homestead)\n\nYou need to add the sites to your `/etc/hosts` file and `Homestead.yaml`. For example, `mywebsite.dev` and `blog.mywebsite.dev`. In the `Homestead.yaml`, you need to map the sites to the same folder.\n\n### Publish\n\nBy running `php artisan vendor:publish --provider=\"Appstract\\Multisite\\MultisiteServiceProvider\"` in your project all files for multisite will be published. The files that will be published are: a migration, a seeder and a config file.\n\n### Seeder\n\nThe seeder will be published but needs to be run when running `php artisan db:seed`, so you need the add `$this-\u003ecall(SitesTableSeeder::class);` to your `DatabaseSeeder.php` file. After migrating and seeding the sites are now present in the database.\n\n## Usage\n\nThis is the main part, within your `routes/web.php` you can set routes for your sites within route groups, like this:\n\n```php\nRoute::group([\n    'domain' =\u003e 'blog.'.config('multisite.host'),\n    'as' =\u003e 'blog.',\n    'middleware' =\u003e 'site:blog'\n], function () {\n    Route::get('/', 'BlogController@homepage')-\u003ename('homepage');\n});\n```\n\nThe magic happens with the site middleware `site:blog`. This will tell your app that the routes within the group are belonging to the blog. It will provide a variable called `$currentSite` in all your views. There is also a config available, which you can access with `Config::get('multisite.site')`.\n\n## Testing\n\n``` bash\n$ composer test\n```\n\n## Contributing\n\nContributions are welcome, [thanks to y'all](https://github.com/appstract/laravel-multisite/graphs/contributors) :)\n\n## About Appstract\n\nAppstract is a small team from The Netherlands. We create (open source) tools for webdevelopment and write about related subjects on [Medium](https://medium.com/appstract). You can [follow us on Twitter](https://twitter.com/teamappstract), [buy us a beer](https://www.paypal.me/teamappstract/10) or [support us on Patreon](https://www.patreon.com/appstract).\n\n## License\n\nThe MIT License (MIT). Please see [License File](LICENSE.md) for more information.\n","funding_links":["https://www.paypal.me/teamappstract/10","https://www.patreon.com/appstract"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fappstract%2Flaravel-multisite","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fappstract%2Flaravel-multisite","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fappstract%2Flaravel-multisite/lists"}