pavlakis/slim-cli 问题修复 & 功能扩展

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

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

pavlakis/slim-cli

最新稳定版本:1.2

Composer 安装命令:

composer require pavlakis/slim-cli

包简介

Making a mock GET request through the CLI and enabling the same application entry point on CLI scripts.

README 文档

README

Build Status Total Downloads Latest Stable Version codecov PHPStan

Slim 3 Framework CLI Request Middleware

This middleware will transform a CLI call into a Request.

Install

Via Composer

composer require pavlakis/slim-cli 

Usage

Pass the parameters in this order

route / method / query string

php public/index.php /status GET event=true

Add it in the middleware section of your application

$app->add(new \pavlakis\cli\CliRequest());

Adding custom parameters:

$app->add( new \pavlakis\cli\CliRequest( new EnvironmentProperties(['SERVER_PORT' => 9000]) ) );

Pass a route to test it with

$app->get('/status', 'PHPMinds\Action\EventStatusAction:dispatch') ->setName('status');

Check you're only using a CLI call

final class EventStatusAction { ... public function dispatch(Request $request, Response $response, $args) { // ONLY WHEN CALLED THROUGH CLI if (PHP_SAPI !== 'cli') { return $response->withStatus(404)->withHeader('Location', '/404'); } if (!$request->getParam('event')) { return $response->withStatus(404)->withHeader('Location', '/404'); } ... } }

Or we can use a PHP Server Interface (SAPI) Middleware to do the SAPI check adding by adding it to a route:

// By default returns a 403 if SAPI not part of the whitelist $app->get('/status', 'PHPMinds\Action\EventStatusAction:dispatch') ->add(new Pavlakis\Middleware\Server\Sapi(["cli"]))

Testing

$ composer test

Contributing

Please see CONTRIBUTING for details.

Credits

Based on Bobby DeVeaux's (@bobbyjason) Gulp Skeleton

License

The BSD 3-Clause License. Please see License File for more information.

统计信息

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

GitHub 信息

  • Stars: 36
  • Watchers: 2
  • Forks: 5
  • 开发语言: PHP

其他信息

  • 授权协议: BSD-3-Clause
  • 更新时间: 2026-01-04

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固