-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
901 additions
and
1 deletion.
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 |
---|---|---|
@@ -0,0 +1,2 @@ | ||
.idea | ||
vendor/ |
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,7 @@ | ||
flux-publish-utils: | ||
stage: build | ||
image: docker-registry.fluxpublisher.ch/flux-publish-utils:latest | ||
script: | ||
- "false" | ||
only: | ||
- main |
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,4 @@ | ||
# CHANGELOG | ||
|
||
## [1.0.0] | ||
* fist-version |
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 |
---|---|---|
@@ -1,2 +1,59 @@ | ||
# dotenv | ||
# flux-eco/dot-env | ||
|
||
Loads .env-Files | ||
|
||
## Usage | ||
|
||
.env-File | ||
|
||
``` | ||
MYSQL_HOST=localhost | ||
MYSQL_DATABASE=projection | ||
MYSQL_USER=emmett | ||
PASSWORD=fluxcapacitor | ||
``` | ||
|
||
loadAndPrint.php | ||
|
||
``` | ||
<?php | ||
require_once __DIR__ . '/../vendor/autoload.php'; | ||
FluxEco\DotEnv\Api::new()->load(__DIR__); | ||
echo getenv('MYSQL_USER').PHP_EOL; | ||
echo getenv('PASSWORD').PHP_EOL; | ||
``` | ||
|
||
output | ||
|
||
``` | ||
emmett | ||
fluxcapacitor | ||
``` | ||
|
||
## functional Usage | ||
|
||
``` | ||
<?php | ||
require_once __DIR__ . '/../vendor/autoload.php'; | ||
fluxy\loadDotEnv(__DIR__); | ||
``` | ||
|
||
## Contributing :purple_heart: | ||
|
||
Please ... | ||
|
||
1. ... register an account at https://git.fluxlabs.ch | ||
2. ... create pull requests :fire: | ||
|
||
## Adjustment suggestions / bug reporting :feet: | ||
|
||
Please ... | ||
|
||
1. ... register an account at https://git.fluxlabs.ch | ||
2. ... ask us for a Service Level Agreement: support@fluxlabs.ch :kissing_heart: | ||
3. ... read and create issues |
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,52 @@ | ||
{ | ||
"name": "flux-eco/dot-env", | ||
"description": "Loads .env-Files", | ||
"version": "1.0.0", | ||
"type": "flux-app", | ||
"keywords": [ | ||
"flux-eco", | ||
"dot-env", | ||
"fluxlabs" | ||
], | ||
"homepage": "https://fluxlabs.ch", | ||
"license": "GPL-3.0-only", | ||
"authors": [ | ||
{ | ||
"name": "fluxlabs ag", | ||
"email": "support@fluxlabs.ch", | ||
"homepage": "https://fluxlabs.ch", | ||
"role": "Developer" | ||
} | ||
], | ||
"support": { | ||
"email": "support@fluxlabs.ch" | ||
}, | ||
"require": { | ||
"php": ">=8.0" | ||
}, | ||
"require-dev": { | ||
|
||
}, | ||
"autoload": { | ||
"files": [ | ||
"fn/loadDotEnv.php" | ||
], | ||
"psr-4": { | ||
"FluxEco\\DotEnv\\": [ | ||
"src/" | ||
], | ||
"fluxy\\": [ | ||
"fn/" | ||
] | ||
} | ||
}, | ||
"config": { | ||
"classmap-authoritative": true, | ||
"optimize-autoloader": true, | ||
"sort-packages": true, | ||
"platform-check": true, | ||
"allow-plugins": { | ||
"composer/package-versions-deprecated": true | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,4 @@ | ||
MYSQL_HOST=localhost | ||
MYSQL_DATABASE=projection | ||
MYSQL_USER=emmett | ||
PASSWORD=fluxcapacitor |
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,8 @@ | ||
<?php | ||
|
||
require_once __DIR__ . '/../vendor/autoload.php'; | ||
|
||
FluxEco\DotEnv\Api::new()->load(__DIR__); | ||
|
||
echo getenv('MYSQL_USER').PHP_EOL; | ||
echo getenv('PASSWORD').PHP_EOL; |
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,8 @@ | ||
<?php | ||
|
||
require_once __DIR__ . '/../vendor/autoload.php'; | ||
|
||
fluxy\loadDotEnv(__DIR__); | ||
|
||
echo getenv('MYSQL_USER').PHP_EOL; | ||
echo getenv('PASSWORD').PHP_EOL; |
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,10 @@ | ||
<?php | ||
|
||
namespace fluxy; | ||
|
||
use FluxEco\DotEnv\Api; | ||
|
||
function loadDotEnv(string $directoryPath) | ||
{ | ||
Api::new()->load($directoryPath); | ||
} |
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,24 @@ | ||
<?php | ||
|
||
namespace FluxEco\DotEnv; | ||
|
||
class Api | ||
{ | ||
private Core\Ports\Service $service; | ||
|
||
private function __construct($service) | ||
{ | ||
$this->service = $service; | ||
} | ||
|
||
public static function new() : self | ||
{ | ||
return new self(Core\Ports\Service::new()); | ||
} | ||
|
||
public function load(string $directoryPath) | ||
{ | ||
$this->service->load($directoryPath); | ||
} | ||
|
||
} |
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,30 @@ | ||
<?php | ||
|
||
namespace FluxEco\DotEnv\Core\Ports; | ||
|
||
class Service | ||
{ | ||
|
||
private function __construct() | ||
{ | ||
|
||
} | ||
|
||
public static function new() | ||
{ | ||
return new self(); | ||
} | ||
|
||
public function load(string $directoryPath) : void | ||
{ | ||
$envFilePath = $directoryPath . '/.env'; | ||
if (!file_exists($envFilePath) === true) { | ||
return; | ||
} | ||
|
||
$lines = file($envFilePath); | ||
foreach ($lines as $line) { | ||
putenv(trim($line)); | ||
} | ||
} | ||
} |