-
-
Save rizqidjamaluddin/b138d894e4f6c4295189 to your computer and use it in GitHub Desktop.
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
SOME_API_KEY=12345 |
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
<?php | |
return [ | |
'key' => env('SOME_API_KEY'); | |
]; |
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
<?php | |
class SomeApiRepository { | |
protected $key; | |
function __construct ($key) { | |
$this->key = $key; | |
// add any other dependencies here, like Guzzle | |
} | |
/** | |
* Abstract stuff to helper protected methods as usual | |
*/ | |
function getSomeInfo() { | |
return $this->httpFetcherDoohikie->grabSoAndSo(); | |
} | |
} |
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
<?php | |
class SomeApiServiceProvider extends ServiceProvider { | |
public function register() { | |
$this->app->bind(SomeApiRepository::class, function ($app) { | |
return new SomeApiRepository($app['config']->get('some-api-config.key')); | |
}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment