Skip to content

Conversation

@58bits
Copy link

@58bits 58bits commented Jul 9, 2014

Added InvalidAlgorithmError class, and reorganised to follow psr-4 layout for autoloading as composer package.

For example in composer.json, you can add the following to autoload the class.

"repositories": {
    "http-signer": {
      "type": "package",
      "package": {
        "name": "gwynne/http-signer",
        "version": "1.0.0",
        "source": {
          "url": "https://github.com/dgwynne/php-http-signature",
          "type": "git",
          "reference": "7abfde5fc7ad29b62446fb59c967458f48227220"
        }
      }
    }
  },

"autoload": {
    "psr-4": {
      "Gwynne\\": "vendor/gwynne/http-signer/src/"
    }
  }

composer install would then automatically clone the repository into the following vendor directory...

── composer.json
├── composer.lock
└── vendor
    ├── autoload.php
    ├── composer
    └── gwynne
        └── http-signer
            ├── LICENSE
            ├── README.md
            └── src
                └── HTTPSignature.php

Using the signature class then becomes...

require 'vendor/autoload.php'; // Loads all vendor related 'requires'.

$date = gmdate(DATE_RFC1123);
$headers = array('date' => $date);

Gwynne\HTTPSignature::sign($headers, array(
    'key' => '46653e78ce9df4f2d9ae93gft5f5c281',
    'keyId' => '18KF2FGK6807ZQA9FGT4',
    'algorithm' => 'hmac-sha1'
));

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant