Skip to content

Commit 85a6170

Browse files
committed
Merge pull request dekalee#1 from VeggieMeat/master
Remove dependency on DotEnv
2 parents aa73b26 + 03d28c8 commit 85a6170

File tree

3 files changed

+15
-18
lines changed

3 files changed

+15
-18
lines changed

README.md

+1-8
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,13 @@ A php library for interacting with AutopilotHQ API http://docs.autopilot.apiary.
88
$ composer require picr/php-autopilothq
99
```
1010

11-
Create an `.env` file
12-
```env
13-
AUTOPILOT_SECRET=your-secret-key
14-
```
15-
1611
## Usage
1712
---
1813
All interaction occurs in the `AutopilotManager` class.
1914

2015
### initialize manager
2116
```php
22-
// NOTE: AUTOPILOT_SECRET must be defined in .env file
23-
// NOTE: if AUTOPILOT_HOST is not defined in .env file, will use 'https://api2.autopilothq.com/v1/'
24-
$manager = new AutopilotManager();
17+
$manager = new AutopilotManager($apiKey);
2518
```
2619

2720
### getContact

composer.json

+6-3
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,15 @@
1414
],
1515
"require": {
1616
"php": ">=5.5.9",
17-
"guzzlehttp/guzzle": "~6.0",
18-
"vlucas/phpdotenv": "~2.2"
17+
"guzzlehttp/guzzle": "~6.0"
1918
},
2019
"require-dev": {
2120
"codeception/codeception": "~2.1",
22-
"codeception/aspect-mock": "dev-master"
21+
"codeception/aspect-mock": "dev-master",
22+
"vlucas/phpdotenv": "~2.2"
23+
},
24+
"suggest": {
25+
"vlucas/phpdotenv": "Allows secrets to be loaded from .env files."
2326
},
2427
"autoload": {
2528
"psr-4": {

src/AutopilotManager.php

+8-7
Original file line numberDiff line numberDiff line change
@@ -30,18 +30,19 @@ class AutopilotManager
3030

3131
/**
3232
* AutopilotManager constructor.
33+
*
34+
* @param string $apiKey
35+
* Autopilot secret key.
36+
* @param string $apiHost
37+
* Autopilot host URI.
3338
*/
34-
public function __construct()
39+
public function __construct($apiKey, $apiHost = null)
3540
{
36-
// load required apikey from config
37-
$this->apiKey = getenv('AUTOPILOT_SECRET');
38-
if ($this->apiKey === null) {
39-
throw AutopilotException::missingApiKey();
40-
}
41+
$this->apiKey = $apiKey;
4142

4243
// instantiate client
4344
$this->client = new Client([
44-
'base_uri' => getenv('AUTOPILOT_HOST') ?: 'https://api2.autopilothq.com/v1/',
45+
'base_uri' => $apiHost ?: 'https://api2.autopilothq.com/v1/',
4546
]);
4647
}
4748

0 commit comments

Comments
 (0)