Skip to content
This repository has been archived by the owner on Dec 31, 2021. It is now read-only.

Commit

Permalink
Enable envoronment configuration via .env
Browse files Browse the repository at this point in the history
  • Loading branch information
morozov committed Oct 9, 2021
1 parent d033716 commit 823615d
Show file tree
Hide file tree
Showing 4 changed files with 219 additions and 3 deletions.
1 change: 1 addition & 0 deletions .gitignore
@@ -1,3 +1,4 @@
/.env
/.phpunit.result.cache
/.phpcs.cache
/infection.log
Expand Down
3 changes: 2 additions & 1 deletion composer.json
Expand Up @@ -21,7 +21,8 @@
"doctrine/coding-standard": "^9.0.0",
"infection/infection": "^0.25",
"phpunit/phpunit": "^9.5",
"vimeo/psalm": "^4.10"
"vimeo/psalm": "^4.10",
"vlucas/phpdotenv": "^5.3"
},
"config": {
"platform": {
Expand Down
210 changes: 209 additions & 1 deletion composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 7 additions & 1 deletion etc/container.php
Expand Up @@ -2,6 +2,7 @@

declare(strict_types=1);

use Dotenv\Dotenv;
use GuzzleHttp\Client as HttpClient;
use KiH\Action\Feed;
use KiH\Action\Index;
Expand All @@ -14,12 +15,17 @@
use Slim\Psr7\Factory\ResponseFactory;
use UltraLite\Container\Container;

if (class_exists(Dotenv::class)) {
Dotenv::createImmutable(dirname(__DIR__))
->safeLoad();
}

return new Container([
Client::class => static function (): Client {
return new VkClient(
new HttpClient(),
'kremhrust',
getenv('VK_ACCESS_TOKEN') ?: ''
$_ENV['VK_ACCESS_TOKEN'] ?? ''
);
},
Generator::class => static function (Container $container): Generator {
Expand Down

0 comments on commit 823615d

Please sign in to comment.