定制 oriondevelops/larashared 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

oriondevelops/larashared

Composer 安装命令:

composer require oriondevelops/larashared

包简介

Shared Hosting Deployment Management for Laravel

README 文档

README

Larashared

Larashared

Latest Version on Packagist Total Downloads

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

"Buy Me A Coffee"
or send your love & energy <3

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_TOKEN to your .env file 🔁

  • You can now copy the default htaccess file and set a random token by the larashared:install Artisan 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.

oriondevelops/larashared 适用场景与选型建议

oriondevelops/larashared 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 8 次下载、GitHub Stars 达 10, 最近一次更新时间为 2023 年 02 月 05 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「laravel」 「oriononairdev」 「larashared」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 oriondevelops/larashared 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 oriondevelops/larashared 我们能提供哪些服务?
定制开发 / 二次开发

基于 oriondevelops/larashared 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 8
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 10
  • 点击次数: 13
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 10
  • Watchers: 2
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-02-05