turanct / shack
PHP git sha 中间件
v1.1.1
2015-03-25 18:23 UTC
Requires
- symfony/http-foundation: ~2.1
- symfony/http-kernel: ~2.1
Requires (Dev)
- phpspec/phpspec: ~2.0
- silex/silex: ~1.2
- stack/builder: ~1.0
This package is auto-updated.
Last update: 2024-08-28 23:06:49 UTC
README
A Stack 中间件,将为应用程序添加一个唯一标识符(sha
)。它将设置一个包含 sha 的自定义头(X-Shack-Sha
)。
$ curl -I http://shack.dev
HTTP/1.1 200 OK
Date: Sat, 06 Dec 2014 17:29:49 GMT
Server: Apache/2.2.22 (Ubuntu)
X-Powered-By: PHP/5.3.10-1ubuntu3.15
Cache-Control: no-cache
X-Shack-Sha: 7c2796aa85d735874ec95c7b4e18a2e0f15d1456
Vary: Accept-Encoding
Content-Type: text/html; charset=UTF-8
示例
<?php $app = new Silex\Application(); $app->get('/', function() use ($app) { return 'Hello World'; }); $stack = new Stack\Builder(); $stack->push('Turanct\Shack', new Turanct\Shack\Git()); $app = $stack->resolve($app);
用法
只需将正确的 Sha 类型作为参数传递给 Turanct\Shack
构造函数(Git,RevisionFile,String),Shack 将负责其他操作。
选项
Turanct\Shack\Git
将在您的服务器上运行 git 命令,以检索当前 HEAD 的 shaTuranct\Shack\RevisionFile
将使用给定文件的 内容作为 sha。这在使用 Capistrano 时特别方便,因为 Capistrano 有一个任务可以创建这些文件。您只需将修订文件路径作为构造函数参数传递。Turanct\Shack\String
接受任何字符串并将其用作 sha。这可能在使用ENV
变量自行设置 sha 时很有用。
如果您想禁用 HTML 页面上的 html sha 印章,只需将 false
传递给 Turanct\Shack
构造函数。
灵感来源
由 Piet pjaspers/shack 从 ruby rack 中间件移植而来