Skip to content

Commit

Permalink
first-version
Browse files Browse the repository at this point in the history
  • Loading branch information
mstuder committed Apr 3, 2022
1 parent d103d93 commit f2f33cf
Show file tree
Hide file tree
Showing 13 changed files with 901 additions and 1 deletion.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.idea
vendor/
7 changes: 7 additions & 0 deletions .gitlab-ci.yml
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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# CHANGELOG

## [1.0.0]
* fist-version
674 changes: 674 additions & 0 deletions LICENSE

Large diffs are not rendered by default.

59 changes: 58 additions & 1 deletion README.md
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
52 changes: 52 additions & 0 deletions composer.json
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
}
}
}
20 changes: 20 additions & 0 deletions composer.lock

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

4 changes: 4 additions & 0 deletions examples/.env
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
8 changes: 8 additions & 0 deletions examples/loadAndPrint.php
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;
8 changes: 8 additions & 0 deletions examples/loadAndPrintFunctional.php
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;
10 changes: 10 additions & 0 deletions fn/loadDotEnv.php
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);
}
24 changes: 24 additions & 0 deletions src/Api.php
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);
}

}
30 changes: 30 additions & 0 deletions src/Core/Ports/Service.php
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));
}
}
}

0 comments on commit f2f33cf

Please sign in to comment.