mmoreram/http-headers-bundle

此包已被弃用且不再维护。未建议替代包。

Symfony 的自定义 HTTP 头定义

v1.1.0 2015-11-18 20:14 UTC

This package is not auto-updated.

Last update: 2018-07-17 10:36:45 UTC


README

Scrutinizer Quality Score SensioLabsInsight

Symfony2 的自定义 HTTP 头

安装 HttpHeadersBundle

您需要在您的 composer.json 文件中添加 require 行

"require": {
    "php": ">=5.3.3",
    "symfony/symfony": "2.3.*",
    ...
    "mmoreram/http-headers-bundle": "dev-master"
},

然后您需要使用 composer 更新您项目的依赖项

php composer.phar update

并在您的 appkernel.php 文件中注册此包

return array(

    // ...
    new Mmoreram\HttpHeadersBundle\HttpHeadersBundle(),
    // ...
);

配置 HttpHeaders Bundle

现在您可以为您的项目配置任意数量的 HTTP 头。您只需在您的 config.yml 文件中为它们提供名称和值即可

http_headers:
    response:
        x_jedi_newton:
            name: X-Jedi-Newton
            values:
                - I can calculate the motion of heavenly bodies, but not the madness of people
                - Errors are not in the art but in the artificers
                - It is the weight, not numbers of experiments that is to be regarded
        x_jedi:
            name: X-Jedi
            values:
                - Meet our team at humans.txt

此包将在每个请求中获取一个随机引用。如果只定义了一个引用,则只输出这个引用。

加入 X-Jedi

有一个名为 X-Jedi 的项目,鼓励所有开发团队在 X-Jedi 的名字下添加他们自己的 http-headers,并附上他们最有代表性的引用。您可以在 X-Jedi 项目 网页上找到更多信息。

Bitdeli Badge