-
Notifications
You must be signed in to change notification settings - Fork 300
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes global environment variables not being taken in by workers (#257)
* Fixes the way Octane handles environment variables * Updates changelog
- Loading branch information
1 parent
f54f249
commit a10804d
Showing
4 changed files
with
57 additions
and
14 deletions.
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
37 changes: 37 additions & 0 deletions
37
src/Commands/Concerns/InteractsWithEnvironmentVariables.php
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,37 @@ | ||
<?php | ||
|
||
namespace Laravel\Octane\Commands\Concerns; | ||
|
||
use Dotenv\Exception\InvalidPathException; | ||
use Dotenv\Parser\Parser; | ||
use Dotenv\Store\StoreBuilder; | ||
use Illuminate\Support\Env; | ||
|
||
trait InteractsWithEnvironmentVariables | ||
{ | ||
/** | ||
* Forgets the current process environment variables. | ||
* | ||
* @return void | ||
*/ | ||
public function forgetEnvironmentVariables() | ||
{ | ||
$variables = collect(); | ||
|
||
try { | ||
$content = StoreBuilder::createWithNoNames() | ||
->addPath(app()->environmentPath()) | ||
->addName(app()->environmentFile()) | ||
->make() | ||
->read(); | ||
|
||
foreach ((new Parser())->parse($content) as $entry) { | ||
$variables->push($entry->getName()); | ||
} | ||
} catch (InvalidPathException $e) { | ||
// .. | ||
} | ||
|
||
$variables->each(fn ($name) => Env::getRepository()->clear($name)); | ||
} | ||
} |
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
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