oriononairdev/larashared
最新稳定版本:v1.0.0
Composer 安装命令:
composer require oriononairdev/larashared
包简介
Shared Hosting Deployment Management for Laravel
README 文档
README
Larashared
Shared Hosting Deployment Management for Laravel
Larashared is a deployment guide and a helper api in shared hosting environments where ssh access is not available.
It allows using basic Artisan commands through an API by sending post requests with a bearer token for authorization. The package can be installed via composer and the configuration file can be published to modify the API path and the token. The package has several endpoints for different Artisan commands like optimizing, enabling/disabling maintenance mode, cache operations, etc.
Disclaimer
Deploying Laravel on shared hosting is not recommended. Check out this article by Pardeep Kumar:
Here’s Why You Should Stay Away From Laravel Shared Hosting
Support me
Installation
You can install the package via composer:
composer require oriondevelops/larashared
You can publish the config file with:
php artisan vendor:publish --tag="larashared-config"
This is the contents of the published config file:
return [ /* |-------------------------------------------------------------------------- | API Path |-------------------------------------------------------------------------- | | This is the URI path where API will be accessible from. Feel free to | change this path to anything you like. | */ 'path' => env('LARASHARED_PATH', 'larashared'), /* |-------------------------------------------------------------------------- | Token |-------------------------------------------------------------------------- | | This value is the token the API will be accessible with. | */ 'token' => env('LARASHARED_TOKEN', '1|gnmyXCnxxN23MAMxx2dCv5BgT4cUOo6ZWSdUPqWT'), ];
Deployment
-
Make a fresh copy of your application 🎁
-
Build your production assets 🔧
# For example npm install npm run build -
Install dependencies excluding dev packages ↙️
composer install --optimize-autoloader --no-dev
npm install --omit=dev
-
Create the .env and fill it according to your shared hosting settings and add
LARASHARED_TOKENto your .env file 🔁 -
You can now copy the default htaccess file and set a random token by the
larashared:installArtisan command ⚙️php artisan larashared:install
-
Move your application with all files and folders to your root folder by FTP 🚀
-
(Optional) Run your migrations using migration endpoint ↗️
Usage
Authorization
Authorization: Bearer <<Your Token>>
You can now send post requests to the endpoints using your token.
POST /larashared/optimize
<?php $client = new Client(); $request = new Request('POST', 'https://example.com/larashared/optimize'); $res = $client->sendAsync($request)->wait(); echo $res->getBody();
Response
{
"success": true,
"data": "Success",
"message": "Command successful."
}
API Endpoints
| HTTP Verbs | Endpoints | Action | Parameters |
|---|---|---|---|
| POST | /larashared/optimize | Run artisan optimize command | |
| POST | /larashared/optimize/clear | Run artisan optimize:clear command | |
| POST | /larashared/maintenance | Enable or disable maintenance mode | status, secret, refresh, retry |
| POST | /larashared/config/cache | Run artisan config:cache command | |
| POST | /larashared/config/clear | Run artisan config:clear command | |
| POST | /larashared/route/cache | Run artisan route:cache command | |
| POST | /larashared/route/clear | Run artisan route:clear command | |
| POST | /larashared/view/cache | Run artisan view:cache command | |
| POST | /larashared/view/clear | Run artisan view:clear command | |
| POST | /larashared/migrate | Run artisan migrate command | seed, force, pretend, step |
| POST | /larashared/migrate/fresh | Run artisan migrate:fresh command | |
| POST | /larashared/migrate/refresh | Run artisan migrate:refresh command | |
| POST | /larashared/migrate/rollback | Run artisan migrate:rollback command | |
| POST | /larashared/migrate/reset | Run artisan migrate:reset command | |
| POST | /larashared/seed | Run artisan db:seed command | class, force |
Maintenance Mode
Form Data
status secret refresh retry
Status should be "up" or "down", it will be down if not specified.
Others are the same options of the artisan command. More information can be found at Laravel Docs.
To be able to use the api in maintenance mode, do not forget to update following middleware.
// app/http/middleware/PreventRequestsDuringMaintenance.php /** * The URIs that should be reachable while maintenance mode is enabled. * * @var array<int, string> */ protected $except = [ 'larashared/*' ];
Migrate
POST /larashared/migrate
POST /larashared/migrate/fresh
POST /larashared/migrate/refresh
POST /larashared/migrate/rollback
POST /larashared/migrate/reset
Form Data
seed force pretend step
Seed
POST /larashared/seed
Form Data
class force
Optionally seeder class can be specified by class parameter.
If you plan to seed your application, make sure dev dependencies like fakerphp/faker are installed.
Credits
License
The MIT License (MIT). Please see License File for more information.
oriononairdev/larashared 适用场景与选型建议
oriononairdev/larashared 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 10 次下载、GitHub Stars 达 10, 最近一次更新时间为 2022 年 10 月 16 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「laravel」 「oriononairdev」 「larashared」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 oriononairdev/larashared 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 oriononairdev/larashared 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 oriononairdev/larashared 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Alfabank REST API integration
Shared Hosting Deployment Management for Laravel
Laravel package for Accurate Online API integration.
Shared RCX Laravel DataTables UI and configuration helpers.
Boot a Laravel project on any machine with one command: app:serve installs missing tools (PHP, Node, Composer, Herd, Docker), creates .env, sets up the database, runs migrations, builds assets, starts a queue worker and serves via Herd, Sail or artisan serve; app:down cleanly stops everything it sta
Branded, diagnostic error pages (500, 403, 404, 419, 503) for Filament — native Filament UI, dark mode and translations out of the box.
统计信息
- 总下载量: 10
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 10
- 点击次数: 13
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2022-10-16
