coufal/laravel-http-cronjob 问题修复 & 功能扩展

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

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

coufal/laravel-http-cronjob

最新稳定版本:v1.3.0

Composer 安装命令:

composer require coufal/laravel-http-cronjob

包简介

A Laravel package to trigger the scheduler via HTTP endpoint.

README 文档

README

Description

This library allows a Laravel application to initiate scheduled tasks through an HTTP request. It lets you trigger Laravel's scheduler from external sources, such as web-based cron job services offered by hosting providers like IONOS or All-Inkl.com. Security for accessing this feature is maintained using a Bearer token, which can be configured using an environment variable.

Installation

To install the package, run the following command in your Laravel project:

composer require coufal/laravel-http-cronjob
# you may optionally publish the config file to config/scheduled-tasks.php by running
php artisan vendor:publish --provider="Coufal\LaravelHttpCronjob\Providers\HttpCronjobServiceProvider"

Configure the Bearer token and a custom endpoint in your .env file. A random token may be generated using: pwgen --secure 256.

HTTP_CRONJOB_TOKEN=your-secure-token-here
HTTP_CRONJOB_ENDPOINT=/custom/scheduler/endpoint
  • HTTP_CRONJOB_TOKEN is used for authenticating the HTTP requests to the scheduled tasks route.
  • HTTP_CRONJOB_ENDPOINT allows you to define a custom route for triggering scheduled tasks. If not set, the default route /scheduler/cronjob is used.

Usage

POST Request

Once configured, you can trigger the Laravel scheduler by making a POST request to the published route (/scheduler/cronjob by default) with the correct Bearer token in the Authorization header:

Authorization: Bearer your-secure-token-here

GET Request

Alternatively, you can trigger the Laravel scheduler by making a GET request to the published route (/scheduler/cronjob by default)

/custom/scheduler/endpoint?token=your-secure-token-here

This can be set up as a web-based cron job pointing to this route to trigger your scheduled tasks remotely.

Security Considerations

Ensure that your Bearer token is kept secure and is only known to the services that require access to trigger the scheduler.

Currently, there is no protection against brute force attacks against the API endpoint, apart from using a long token.

Contributing

Contributions to the package are welcome! Please feel free to submit pull requests or open issues to suggest improvements or report bugs.

License

This package is open-sourced software licensed under the MIT license.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-04-11

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固