sagor/github-updater 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

sagor/github-updater

Composer 安装命令:

composer require sagor/github-updater

包简介

A Laravel package for automated Github pulls and Artisan commands by moh-sagor.

README 文档

README

A Laravel package for automated GitHub pulls and running Artisan commands, developed by Md Sagor Hossain.

Description

sagor/github-updater is a Laravel package that simplifies pulling the latest changes from a GitHub repository and executing predefined Artisan commands (e.g., migrations, seeding) in a single step. It provides both a console command (php artisan github:pull) and a web route (/github-pull) for convenience.

Requirements

  • PHP 7.4–8.4
  • Laravel 8.x, 9.x, 10.x, 11.x or 12.x
  • Git installed on the server

Note: PHP 7.4 reached end-of-life on November 28, 2022, and no longer receives security updates. We recommend using PHP 8.0 or higher for security and performance reasons.

Installation

Install the package via Composer:

composer require sagor/github-updater

The package uses Laravel's auto-discovery to register the service provider. If auto-discovery is disabled, manually add the service provider to config/app.php:

'providers' => [
    // ...
    Sagor\GithubUpdater\Providers\GithubUpdaterServiceProvider::class,
],

Configuration

Publish the configuration file to customize the package settings:

php artisan vendor:publish --tag=config

This will create a config/github-updater.php file with the following default configuration:

return [
    'github_token' => env('GITHUB_TOKEN', ''),
    'github_username' => env('GITHUB_USERNAME', ''),
    'github_repo_link' => env('GITHUB_REPO_LINK', ''),
    'artisan_commands' => env('ARTISAN_COMMANDS', 'php artisan migrate --force, php artisan db:seed'),
];

Environment Variables

Set the following environment variables in your .env file:

GITHUB_TOKEN=your_github_personal_access_token
GITHUB_USERNAME=your_github_username
GITHUB_REPO_LINK=your_repository_link (e.g., github.com/moh-sagor/project-url.git)
ARTISAN_COMMANDS="php artisan migrate --force,php artisan db:seed"

Security Note: Ensure your GITHUB_TOKEN is kept secure and not exposed in logs or public repositories.

Usage

1. Console Command

Run the following Artisan command to pull the latest changes from GitHub and execute the configured Artisan commands:

php artisan github:pull

This command:

  • Executes git pull to fetch the latest changes from the GitHub repository.
  • Runs the Artisan commands specified in ARTISAN_COMMANDS (e.g., php artisan migrate --force and php artisan db:seed).

Output: The command provides feedback on the progress and any errors encountered.

2. Web Route

Access the web route to trigger the same functionality via a browser or API:

GET /github-pull

This route:

  • Pulls the latest changes from GitHub.
  • Executes the configured Artisan commands.
  • Displays the output in a terminal-like format in the browser.

Note: The route is protected by the web middleware. Ensure you have appropriate authentication or authorization middleware if you want to restrict access.

If You want Another middleware you can you use in your web.php file.

Route::middleware(['web', 'auth'])->group(function () {
    Route::get('/github-pull', [GithubController::class, 'executeCommands'])
        ->name('github.pull');
});

Example Workflow

  1. Configure your .env file with your GitHub credentials and repository link.
  2. Run the console command or access the web route to pull updates and run migrations/seeds automatically.

Testing

To test the package locally:

  1. Clone the repository and install dependencies:
    composer install
  2. Set up a Laravel project with PHP 7.4–8.4 and Laravel 8–11.
  3. Configure the environment variables and test the console command and web route.

Contributing

Contributions are welcome! Please follow these steps:

  1. Fork the repository.
  2. Create a new branch for your feature or bug fix.
  3. Submit a pull request with your changes.

License

This package is open-source software licensed under the MIT License.

Support

For issues or questions, please open an issue on the GitHub repository.

Acknowledgments

Developed by Md Sagor Hossain (sagorhassain4@gmail.com).

Notes for Customization

  • Replace https://github.com/moh-sagor/github-updater with your actual GitHub repository URL if it differs.
  • If you have additional features, testing instructions, or contributors, add them to the relevant sections.
  • If you have a LICENSE file, ensure it exists in your repository and matches the MIT License mentioned.

This README is concise, clear, and follows best practices for open-source Laravel packages. You can further expand it with screenshots, more detailed examples, or additional sections like "Changelog" or "Roadmap" if applicable. Let me know if you’d like to adjust or add anything specific!

sagor/github-updater 适用场景与选型建议

sagor/github-updater 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 670 次下载、GitHub Stars 达 0, 最近一次更新时间为 2025 年 02 月 21 日, 在 PHP 生态内属于活跃度较高的组件。

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

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

围绕 sagor/github-updater 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-02-21