christoph-kluge/cloudfront-edge-php-adapter
Composer 安装命令:
composer require christoph-kluge/cloudfront-edge-php-adapter
包简介
A cloudfront edge event transformer for symfony or laravel request objects
README 文档
README
This small package allows you to transform a Cloudfront@Edge Event into a proper Request-Object
Install
To install via Composer, use the command below, it will automatically detect the latest version and bind it with ^.
composer require christoph-kluge/cloudfront-edge-php-adapter
Usage Example (long running process - one process for multiple requests)
Please take care that your application MAY require adoptions to run in a long-running-process.
Advantages:
- Your app is always warm after ther initial request
- Leverage full potential of opcache
Performance Measurements
This code runs in a production environment api. Almost every endpoint responsds in <10ms (server-response time) w/o the usage of memcache/redis/..
#!/opt/bin/php <?php use Bref\Runtime\LambdaRuntime; $appRoot = getenv('LAMBDA_TASK_ROOT'); require $appRoot . '/vendor/autoload.php'; /** @var \App\Extensions\Foundation\Application $app */ $app = require_once $appRoot . '/bootstrap/app.php'; /** @var CloudfrontEdgeHandler $handler */ $handler = $app->make(CloudfrontEdgeHandler::class); $lambdaRuntime = LambdaRuntime::fromEnvironmentVariable(); while (true) { $lambdaRuntime->processNextEvent($handler); }
Usage (new process per request)
#!/opt/bin/php <?php $appRoot = getenv('LAMBDA_TASK_ROOT'); require $appRoot . '/vendor/autoload.php'; /** @var \Illuminate\Foundation\Application $app */ $app = require_once $appRoot . '/bootstrap/app.php'; lambda($app->make(CloudfrontEdgeHandler::class));
Features
- Support requests with different methods (GET, HEAD, POST, PUT, DELETE, ..)
- Support laravel's dedicated response objects (Response, RedirectResponse, JsonResponse)
- Support post requests from html forms with content-type : x-www-form-urlencoded
- Support cookies
- Origin custom - Read custom headers
- Origin s3 - Read custom headers
- Response might send headers as multiple list-items inside the response
- Attachments - Single (
<input name="single"/>) - Attachments - Multiple - single named (
<input name="single_1"/><input name="single_2"/>) - Attachments - Multiple - array based input (
<input name="file_as_array[]"/><input name="file_as_array[]"/>) - Attachments - Multiple - array based with multiple flag (
<input name="files_as_array_multiple[]" multiple/>)
TODOs
- Attachments - Multiple - single named with multiple flag (
<input name="single_with_multiple" multiple/>) - Attachments - Multiple - multi-dimenionsional input name w/o multiple flag (
<input name="myfile[a][b]"/>) - Attachments - Multiple - multi-dimenionsional input name w/ multiple flag (
<input name="myfile[a][b]"multiple/>) - Attachments - Multiple - multi-dimenionsional input name with array w/o multiple flag (
<input name="myfile[a][b][]"/>) - Attachments - Multiple - multi-dimenionsional input name with array w/ multiple flag (
<input name="myfile[a][b][]" multiple/>) - Check POST with different content-types (json, x-www-form-urlencode, ..?)
- Check 204 responses with JSON why they return "{}" instead of ""
- Cloudfront MAY send multiple list-items for a single header
- Origin custom - Origin Protocol Policy (Mid prio - I guess there might be use-cases where SSL is not used)
- Origin custom - Read different path (Low prio - imo not required for lambda)
- Origin custom - Ssl protocol (Low prio - imo not required for lambda)
- Origin s3 - Origin Protocol Policy (Mid prio - I guess there might be use-cases where SSL is not used)
- Origin s3 - Read different path (Low prio - imo not required for lambda)
- Origin s3 - Restrict Bucket (Low prio - imo not required for lambda)
christoph-kluge/cloudfront-edge-php-adapter 适用场景与选型建议
christoph-kluge/cloudfront-edge-php-adapter 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 91 次下载、GitHub Stars 达 3, 最近一次更新时间为 2019 年 08 月 24 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 christoph-kluge/cloudfront-edge-php-adapter 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 christoph-kluge/cloudfront-edge-php-adapter 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 91
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 3
- 点击次数: 5
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2019-08-24