{"id":20215295,"url":"https://github.com/foxws/laravel-multidomain","last_synced_at":"2026-01-16T00:34:58.644Z","repository":{"id":57749799,"uuid":"524771326","full_name":"foxws/laravel-multidomain","owner":"foxws","description":" Laravel extension for a multi domain/tenant setting","archived":true,"fork":false,"pushed_at":"2023-10-09T18:58:41.000Z","size":84,"stargazers_count":3,"open_issues_count":3,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-03-18T06:13:02.466Z","etag":null,"topics":["ddd","domain","domain-driven-design","laravel","tenant"],"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/foxws.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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":"2022-08-14T20:19:10.000Z","updated_at":"2024-08-11T10:02:20.000Z","dependencies_parsed_at":"2023-02-01T03:45:34.998Z","dependency_job_id":null,"html_url":"https://github.com/foxws/laravel-multidomain","commit_stats":null,"previous_names":[],"tags_count":13,"template":false,"template_full_name":"spatie/package-skeleton-laravel","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/foxws%2Flaravel-multidomain","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/foxws%2Flaravel-multidomain/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/foxws%2Flaravel-multidomain/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/foxws%2Flaravel-multidomain/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/foxws","download_url":"https://codeload.github.com/foxws/laravel-multidomain/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252833920,"owners_count":21811276,"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":["ddd","domain","domain-driven-design","laravel","tenant"],"created_at":"2024-11-14T06:21:10.325Z","updated_at":"2025-05-07T07:33:19.413Z","avatar_url":"https://github.com/foxws.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# A Laravel extension for a multi domain/tenant setting\n\n[![Latest Version on Packagist](https://img.shields.io/packagist/v/foxws/laravel-multidomain.svg?style=flat-square)](https://packagist.org/packages/foxws/laravel-multidomain)\n[![GitHub Tests Action Status](https://img.shields.io/github/workflow/status/foxws/laravel-multidomain/run-tests?label=tests)](https://github.com/foxws/laravel-multidomain/actions?query=workflow%3Arun-tests+branch%3Amain)\n[![GitHub Code Style Action Status](https://img.shields.io/github/workflow/status/foxws/laravel-multidomain/Fix%20PHP%20code%20style%20issues?label=code%20style)](https://github.com/foxws/laravel-multidomain/actions?query=workflow%3A\"Fix+PHP+code+style+issues\"+branch%3Amain)\n[![Total Downloads](https://img.shields.io/packagist/dt/foxws/laravel-multidomain.svg?style=flat-square)](https://packagist.org/packages/foxws/laravel-multidomain)\n\n## Description\n\nThis package allows a single Laravel application to work with multiple domains/tenants.\n\nIt is intended to complement a multi-tenancy package such as [spatie/laravel-multitenancy](https://github.com/spatie/laravel-multitenancy) (tested), [archtechx/tenancy](https://github.com/archtechx/tenancy), etc.\n\nIt allows caching of configs, routes \u0026 views, and is made to be easy to install, as there is no need to modify the core of the Laravel Framework.\n\n\u003e **TIP:** See [foxws/laravel-multidomain-demo](https://github.com/foxws/laravel-multidomain-demo) for a boilerplate.\n\n## Installation\n\nInstall the package via composer:\n\n```bash\ncomposer require foxws/laravel-multidomain\n```\n\nPublish the config file with:\n\n```bash\nphp artisan vendor:publish --tag=\"multidomain-config\"\n```\n\nTo prevent domain abuse, register the provided middlewares:\n\n```php\nprotected $middlewareGroups = [\n    'web' =\u003e [\n        // ...\n        \\Foxws\\MultiDomain\\Middlewares\\NeedsDomain::class,\n        \\Foxws\\MultiDomain\\Middlewares\\EnsureValidDomainSession::class,\n    ]\n];\n```\n\n## Usage\n\nThe package will scan any subfolder (as in domain) located in `app\\Domain` (customisable namespace) containing a `domain.json` file.\n\ne.g. `app\\Domain\\Example\\domain.json`:\n\n```json\n{\n    \"name\": \"Example\",\n    \"domain\": {\n        \"local\": \"example.test\",\n        \"staging\": \"example.dev\",\n        \"production\": \"example.com\"\n    }\n}\n```\n\n\u003e **NOTE:** The `domain` array matches the environment set in `.env`, e.g. `APP_ENV=local` will use `example.test` as it's (routing) base. The `name` is converted to a (slug) prefix and is to be used for registering components, routes, views, etc.\n\nThe structure of each domain should look like this, using `app\\Domain\\Example` as it's root path:\n\n| Path                   | Description                              | Cacheable |\n| ---------------------- | ---------------------------------------- | --------- |\n| Routes\\web.php         | The domain web routes.                   | ✅        |\n| Routes\\api.php         | The domain api routes.                   | ✅        |\n| Config\\\\\\*.php         | The domain config files.                 | ✅        |\n| Providers              | The domain providers (optional).         |           |\n| Resources\\Components   | The domain Blade components (optional).  | ✅        |\n| Resources\\Translations | The domain translation files (optional). |           |\n| Resources\\Views        | The domain Blade views (optional).       | ✅        |\n\nIt will register each config, routes, views, components, using the domain's namespace in slug, e.g. `example`, `foo-bar`.\n\nTo interact with the domain(s), one may use the following:\n\n| Helper                          | Description                                             |\n| ------------------------------- | ------------------------------------------------------- |\n| `config('example.app.name')`    | Would return the name of the application.               |\n| `route('example.home')`         | Would return the route to `/`.                          |\n| `view('example::home')`         | Would return the `home.blade.php` located in views.     |\n| `\u003cx-example::menu-component /\u003e` | Would return the `MenuComponent` located in components. |\n\nWhen you have installed `livewire/livewire`, use the following helpers:\n\n| Helper                                | Description                                           |\n| ------------------------------------- | ----------------------------------------------------- |\n| `@livewire('example.component-name')` | @livewire blade directive.                            |\n| `\u003clivewire:example.component-name /\u003e` | \u003clivewire: tag syntax.                                |\n\n## Testing\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](https://github.com/foxws/.github/blob/main/CONTRIBUTING.md) for details.\n\n## Security Vulnerabilities\n\nPlease review [our security policy](../../security/policy) on how to report security vulnerabilities.\n\n## Credits\n\n- [laravel-modules](https://github.com/nWidart/laravel-modules)\n- [Spatie](https://github.com/spatie)\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%2Ffoxws%2Flaravel-multidomain","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffoxws%2Flaravel-multidomain","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffoxws%2Flaravel-multidomain/lists"}