appstract/laravel-multisite
Composer 安装命令:
composer require appstract/laravel-multisite
包简介
Multisite setup for Laravel
README 文档
README
With this package it is possible to build multiple sites/(sub)domains on one codebase.
Installation
You can install the package via composer:
composer require appstract/laravel-multisite
Config (hosts, homestead)
You 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.
Publish
By 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.
Seeder
The seeder will be published but needs to be run when running php artisan db:seed, so you need the add $this->call(SitesTableSeeder::class); to your DatabaseSeeder.php file. After migrating and seeding the sites are now present in the database.
Usage
This is the main part, within your routes/web.php you can set routes for your sites within route groups, like this:
Route::group([ 'domain' => 'blog.'.config('multisite.host'), 'as' => 'blog.', 'middleware' => 'site:blog' ], function () { Route::get('/', 'BlogController@homepage')->name('homepage'); });
The 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').
Testing
$ composer test
Contributing
Contributions are welcome, thanks to y'all :)
About Appstract
Appstract is a small team from The Netherlands. We create (open source) tools for webdevelopment and write about related subjects on Medium. You can follow us on Twitter, buy us a beer or support us on Patreon.
License
The MIT License (MIT). Please see License File for more information.
appstract/laravel-multisite 适用场景与选型建议
appstract/laravel-multisite 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 11.25k 次下载、GitHub Stars 达 214, 最近一次更新时间为 2017 年 03 月 01 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「appstract」 「laravel-multisite」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 appstract/laravel-multisite 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 appstract/laravel-multisite 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 appstract/laravel-multisite 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Run Dusk tests on Safari
Run Dusk tests in Opera
Laravel packe for Moneybird
Keep stock for Eloquent models
Module provides Magento 2 with missing features
Global options loaded from the database
统计信息
- 总下载量: 11.25k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 214
- 点击次数: 17
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2017-03-01