-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #36 from RogierW/http-client-patch1
Introduce 'HttpClientInterface' and implementation follow-up
- Loading branch information
Showing
29 changed files
with
496 additions
and
250 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,12 +23,26 @@ You can install the package via composer: | |
|
||
## Usage | ||
|
||
You can create an instance of `Rogierw\RwAcme\Api` client. | ||
Create an instance of `Rogierw\RwAcme\Api` client and provide it with a local account that will be used to store the account keys. | ||
|
||
```php | ||
$client = new Api('[email protected]', __DIR__ . '/__account'); | ||
$localAccount = new \Rogierw\RwAcme\Support\LocalFileAccount(__DIR__.'/__account', '[email protected]'); | ||
$client = new Api(localAccount: $localAccount); | ||
``` | ||
|
||
You could also create a client and pass the local account data later: | ||
|
||
```php | ||
$client = new Api(); | ||
|
||
// Do some stuff. | ||
|
||
$localAccount = new \Rogierw\RwAcme\Support\LocalFileAccount(__DIR__.'/__account', '[email protected]'); | ||
$client->setLocalAccount($localAccount); | ||
``` | ||
|
||
> Please note that **setting a local account is required** before making any of the calls detailed below. | ||
### Creating an account | ||
```php | ||
if (!$client->account()->exists()) { | ||
|
@@ -39,6 +53,10 @@ if (!$client->account()->exists()) { | |
$account = $client->account()->get(); | ||
``` | ||
|
||
### Difference between `account` and `localAccount` | ||
- `account` is the account created at the ACME (Let's Encrypt) server with data from the `localAccount`. | ||
- `localAccount` handles the private/public key pair and contact email address used to sign requests to the ACME server. Depending on the implementation, this data is stored locally or, for example, in a database. | ||
|
||
### Creating an order | ||
```php | ||
$order = $client->order()->new($account, ['example.com']); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.3/phpunit.xsd" | ||
bootstrap="vendor/autoload.php" | ||
colors="true" | ||
> | ||
<testsuites> | ||
<testsuite name="Test Suite"> | ||
<directory suffix="Test.php">./tests</directory> | ||
</testsuite> | ||
</testsuites> | ||
<source> | ||
<include> | ||
<directory suffix=".php">./app</directory> | ||
<directory suffix=".php">./src</directory> | ||
</include> | ||
</source> | ||
</phpunit> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.