2017 © Pedro Peláez
 

library shack

Stack PHP git sha middleware

image

turanct/shack

Stack PHP git sha middleware

  • Wednesday, March 25, 2015
  • by turanct
  • Repository
  • 1 Watchers
  • 0 Stars
  • 3 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 4 Versions
  • 0 % Grown

The README.md

Turanct/Shack

A Stack middleware that will add a unique identifier (sha) to the application. It will set a custom header (X-Shack-Sha) containing the sha., (*1)

$ 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

Example

``` php <?php, (*2)

$app = new Silex\Application();, (*3)

$app->get('/', function() use ($app) { return 'Hello World'; });, (*4)

$stack = new Stack\Builder(); $stack->push('Turanct\Shack', new Turanct\Shack\Git()); $app = $stack->resolve($app); ```, (*5)

Usage

Just pass in the right Sha type as argument to the Turanct\Shack constructor (Git, RevisionFile, String), and Shack will take care of the rest., (*6)

Options: - Turanct\Shack\Git will run a git command on your server, to retreive the current HEAD's sha - Turanct\Shack\RevisionFile will use the contents of a given file as sha. This is particulary handy when using Capistrano, as there's a Capistrano task to create these files. You can just pass the revision file path as a constructor parameter. - Turanct\Shack\String takes any string and uses that as the sha. This might be handy to use when you want to set the sha yourself, e.g. using ENV variables., (*7)

If you want to disable the html sha stamp on your html pages, just pass false to the Turanct\Shack constructor., (*8)

Inspiration

Ported from the ruby rack middleware by Piet pjaspers/shack, (*9)

The Versions