Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace getenv() with env() #1121

Merged
merged 1 commit into from
Mar 6, 2021
Merged

Conversation

alexweissman
Copy link
Member

See #1098. Not sure if we want to merge this in for a revision or save for another minor version.

@lcharette
Copy link
Member

So env is a magic helper method of Laravel? Not sure I like that kind of magic, after the str_contain fiasco. I wonder if they have a namespaces equivalent, like Str:: method ?

If it doesn't change .env value, I don't see why we couldn't merge in hotfix ?

@lcharette lcharette linked an issue Nov 25, 2020 that may be closed by this pull request
Copy link
Member

@lcharette lcharette left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, there is a namespaced equivalent : https://github.com/illuminate/support/blob/master/Env.php

I think it would be better long term...

@alexweissman
Copy link
Member Author

I would say we should just follow the same pattern as Laravel, which uses the env helper in config files and tests: https://github.com/laravel/laravel/blob/8.x/config/database.php. I think this makes sense because the namespace could change in subsequent versions of Laravel but the helper method would still be independent of the namespace.

They do use Env:: in namespaced code, if we wanted to be consistent there. Note that unlike the str_ helpers, env has not been deprecated.

Copy link
Member

@lcharette lcharette left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair enough

@codecov
Copy link

codecov bot commented Dec 10, 2020

Codecov Report

Merging #1121 (86a094e) into hotfix (9467ddf) will not change coverage.
The diff coverage is 33.33%.

Impacted file tree graph

@@            Coverage Diff            @@
##             hotfix    #1121   +/-   ##
=========================================
  Coverage     67.81%   67.81%           
+ Complexity     1981     1978    -3     
=========================================
  Files           170      170           
  Lines          6926     6926           
=========================================
  Hits           4697     4697           
  Misses         2229     2229           
Impacted Files Coverage Δ Complexity Δ
app/sprinkles/core/src/Bakery/DebugCommand.php 0.00% <0.00%> (ø) 12.00 <0.00> (ø)
app/sprinkles/core/src/Util/CheckEnvironment.php 2.87% <0.00%> (ø) 43.00 <0.00> (-1.00)
...les/core/src/ServicesProvider/ServicesProvider.php 88.17% <100.00%> (ø) 27.00 <0.00> (-1.00)
app/system/Bakery/BaseCommand.php 100.00% <100.00%> (ø) 3.00 <0.00> (-1.00)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 9467ddf...86a094e. Read the comment docs.

@lcharette lcharette added this to the 4.5.0 milestone Mar 5, 2021
@lcharette lcharette changed the base branch from hotfix to develop March 6, 2021 21:14
@lcharette lcharette merged commit 98727bd into develop Mar 6, 2021
lcharette added a commit that referenced this pull request Mar 6, 2021
@lcharette
Copy link
Member

Note there was actually an issue with this PR that appeared after merge. See temp fix in 926b9be

Error : https://github.com/userfrosting/UserFrosting/actions/runs/628080953

Looks like env doesn't use the loaded env right above :

try {
$dotenv = Dotenv::create(\UserFrosting\APP_DIR);
$dotenv->load();
} catch (InvalidPathException $e) {
// Skip loading the environment config file if it doesn't exist.
}
// Get configuration mode from environment
// TODO : Change to env. It doesn't looks likes it work with dotenv load above.
// $mode = env('UF_MODE', '');
$mode = getenv('UF_MODE') ?: '';

@lcharette lcharette deleted the alexweissman-patch-20201124 branch April 22, 2021 00:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Use Laravel's env helper instead of getenv
2 participants