Skip to content

Commit 7cf10ab

Browse files
author
Jochem
committed
Changed default file to .yml extension, instead of .yaml to better match common practices.
1 parent c5606e6 commit 7cf10ab

File tree

16 files changed

+39
-45
lines changed

16 files changed

+39
-45
lines changed

README.md

Lines changed: 17 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
Maatwebsite\Yamlenv
22
==========
33

4-
Reads env.yaml and makes a validated list of variables available as environment variables.
4+
Reads env.yml and makes a validated list of variables available as environment variables.
55

66
This is package is based on [vlucas/phpdotenv](https://github.com/vlucas/phpdotenv).
77

88
[![Build Status](https://travis-ci.org/Maatwebsite/yamlenv.svg?branch=master)](https://travis-ci.org/Maatwebsite/yamlenv.svg?branch=master)
99

10-
Why choose Yaml over env.yaml?
10+
Why choose Yaml over env.yml?
1111
---------
12-
The benefits of using a env.yaml file or similar has been proven a long time ago.
12+
The benefits of using a env.yml file or similar has been proven a long time ago.
1313
The popularity of [vlucas/phpdotenv](https://github.com/vlucas/phpdotenv) and
1414
similar packages is a testament of this.
1515
There is no reason why you shouldn't use a package like that in your projects,
@@ -19,7 +19,7 @@ In case of larger, enterprise scale, applications, the amount of environment
1919
settings might very quickly become unmanageable. If it's a multi tenant system een more so. And if you're supporting different versions of the application with it's own list of required environment settings, it soon becomes a necessity to automate this process.
2020

2121
These are largely the reasons we decided to move towards Yaml. It provides
22-
a few simple advantages over env.yaml files:
22+
a few simple advantages over env.yml files:
2323
* It allows nesting, to allow grouping of certain settings ( like database
2424
connection credentials ).
2525
* It is easily readable by human as well as multiple automated deployment
@@ -46,30 +46,30 @@ great base to work from!
4646

4747
Of course there are a few things unique to Yamlenv, and that has been added as well.
4848

49-
The `env.yaml` file is generally kept out of version control since it can contain
50-
sensitive API keys and passwords. A separate `env.yaml.dist` file can be created
49+
The `env.yml` file is generally kept out of version control since it can contain
50+
sensitive API keys and passwords. A separate `env.yml.dist` file can be created
5151
with all the required environment variables defined except for the sensitive
5252
ones, which are either user-supplied for their own development environments or
5353
are communicated elsewhere to project collaborators. The project collaborators
54-
then independently copy the `env.yaml.dist` file to a local `env.yaml` and ensure
54+
then independently copy the `env.yml.dist` file to a local `env.yml` and ensure
5555
all the settings are correct for their local environment, filling in the secret
56-
keys or providing their own values when necessary. In this usage, the `env.yaml`
56+
keys or providing their own values when necessary. In this usage, the `env.yml`
5757
file should be added to the project's `.gitignore` file so that it will never
5858
be committed by collaborators. This usage ensures that no sensitive passwords
5959
or API keys will ever be in the version control history so there is less risk
6060
of a security breach, and production values will never have to be shared with
6161
all project collaborators.
6262

63-
Add your application configuration to a `env.yaml` file in the root of your
64-
project. **Make sure the `env.yaml` file is added to your `.gitignore` so it is not
63+
Add your application configuration to a `env.yml` file in the root of your
64+
project. **Make sure the `env.yml` file is added to your `.gitignore` so it is not
6565
checked-in the code**
6666

6767
```shell
6868
S3_BUCKET: "yamlenv"
6969
SECRET_KEY: "secret_key"
7070
```
7171

72-
Now create a file named `env.yaml.dist` and check this into the project. This
72+
Now create a file named `env.yml.dist` and check this into the project. This
7373
should have the ENV variables you need to have set, but the values should
7474
either be blank or filled with dummy data. The idea is to let people know what
7575
variables are required, but not give them the sensitive production values.
@@ -79,14 +79,14 @@ S3_BUCKET: "devbucket"
7979
SECRET_KEY: "abc123"
8080
```
8181

82-
You can then load `env.yaml` in your application with:
82+
You can then load `env.yml` in your application with:
8383

8484
```php
8585
$yamlenv = new Yamlenv\Yamlenv(__DIR__);
8686
$yamlenv->load();
8787
```
8888

89-
Optionally you can pass in a filename as the second parameter, if you would like to use something other than `env.yaml`
89+
Optionally you can pass in a filename as the second parameter, if you would like to use something other than `env.yml`
9090

9191
```php
9292
$yamlenv = new Yamlenv\Yamlenv(__DIR__, 'myconfig');
@@ -122,7 +122,7 @@ s3_bucket: "will_be_uppercase"
122122
```
123123

124124
```php
125-
$yamlenv = new Yamlenv\Yamlenv(__DIR__, 'emv.yaml', true);
125+
$yamlenv = new Yamlenv\Yamlenv(__DIR__, 'emv.yml', true);
126126
$yamlenv->load();
127127
```
128128

@@ -253,7 +253,7 @@ allowed value
253253

254254
### Comments
255255

256-
You can comment your `env.yaml` file using the `#` character. E.g.
256+
You can comment your `env.yml` file using the `#` character. E.g.
257257
This follows the normal Yaml syntax rules
258258

259259
```shell
@@ -281,18 +281,12 @@ Usage Notes
281281
-----------
282282

283283
When a new developer clones your codebase, they will have an additional
284-
**one-time step** to manually copy the `env.yaml.dist` file to `env.yaml` and fill-in
284+
**one-time step** to manually copy the `env.yml.dist` file to `env.yml` and fill-in
285285
their own values (or get any sensitive values from a project co-worker).
286286

287287
Yamlenv is made for development environments, and generally should not be
288288
used in production. In production, the actual environment variables should be
289-
set so that there is no overhead of loading the `env.yaml` file on each request.
289+
set so that there is no overhead of loading the `env.yml` file on each request.
290290
This can be achieved via an automated deployment process with tools like
291291
Vagrant, chef, or Puppet, or can be set manually with cloud hosts like
292292
Pagodabox and Heroku.
293-
294-
### Command Line Scripts
295-
296-
If you need to use environment variables that you have set in your `env.yaml` file
297-
in a command line script that doesn't use the Yamlenv library, you can `source`
298-
it into your local shell session:

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "maatwebsite/yamlenv",
3-
"description": "Reads `env.yaml` and makes a validated list of variables available as environment variables",
3+
"description": "Reads `env.yml` and makes a validated list of variables available as environment variables",
44
"keywords": ["env", "yaml", "environment"],
55
"license" : "LGPL",
66
"authors" : [

src/Yamlenv.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class Yamlenv
3232
* @param string $file
3333
* @param bool $castToUpper
3434
*/
35-
public function __construct($path, $file = 'env.yaml', $castToUpper = false)
35+
public function __construct($path, $file = 'env.yml', $castToUpper = false)
3636
{
3737
$this->filePath = $this->getFilePath($path, $file);
3838
$this->castToUpper = $castToUpper;
@@ -100,7 +100,7 @@ public function getLoader()
100100
protected function getFilePath($path, $file)
101101
{
102102
if (!is_string($file)) {
103-
$file = 'env.yaml';
103+
$file = 'env.yml';
104104
}
105105

106106
$filePath = rtrim($path, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . $file;

tests/Yamlenv/LoaderTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ function apache_setenv($string) {
4848

4949
public function setUp()
5050
{
51-
$this->folder = dirname(__DIR__) . '/fixtures/valid/env.yaml';
51+
$this->folder = dirname(__DIR__) . '/fixtures/valid/env.yml';
5252

5353
// Generate a new, random keyVal.
5454
$this->keyVal(true);
@@ -138,7 +138,7 @@ public function testFlattenNestedValuesThrowsExceptionWithDuplication()
138138
{
139139
$this->clearEnv();
140140

141-
$immutableLoader = new Loader(dirname(__DIR__) . '/fixtures/valid/duplicates_nested.yaml', true);
141+
$immutableLoader = new Loader(dirname(__DIR__) . '/fixtures/valid/duplicates_nested.yml', true);
142142
$immutableLoader->load();
143143
}
144144

tests/Yamlenv/YamlenvTest.php

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public function testCommentedYamlenvLoadsEnvironmentVars()
4242
{
4343
$this->clearEnv();
4444

45-
$yamlenv = new Yamlenv($this->fixturesFolder, 'commented.yaml');
45+
$yamlenv = new Yamlenv($this->fixturesFolder, 'commented.yml');
4646
$yamlenv->load();
4747
$this->assertSame('bar', getenv('CFOO'));
4848
$this->assertFalse(getenv('CBAR'));
@@ -57,7 +57,7 @@ public function testQuotedYamlenvLoadsEnvironmentVars()
5757
{
5858
$this->clearEnv();
5959

60-
$yamlenv = new Yamlenv($this->fixturesFolder, 'quoted.yaml');
60+
$yamlenv = new Yamlenv($this->fixturesFolder, 'quoted.yml');
6161
$yamlenv->load();
6262
$this->assertSame('bar', getenv('QFOO'));
6363
$this->assertSame('baz', getenv('QBAR'));
@@ -73,7 +73,7 @@ public function testQuotedYamlenvLoadsEnvironmentVars()
7373
*/
7474
public function testSpacedValuesWithoutQuotesThrowsException()
7575
{
76-
$yamlenv = new Yamlenv(dirname(__DIR__) . '/fixtures/invalid', 'invalid.yaml');
76+
$yamlenv = new Yamlenv(dirname(__DIR__) . '/fixtures/invalid', 'invalid.yml');
7777
$yamlenv->load();
7878
}
7979

@@ -155,7 +155,7 @@ public function testYamlenvNestedEnvironmentVars()
155155
{
156156
$this->clearEnv();
157157

158-
$yamlenv = new Yamlenv($this->fixturesFolder, 'nested.yaml');
158+
$yamlenv = new Yamlenv($this->fixturesFolder, 'nested.yml');
159159
$yamlenv->load();
160160

161161
$this->assertSame('Hello', $_ENV['NVAR1']);
@@ -230,7 +230,7 @@ public function testYamlenvTrimmedKeys()
230230
{
231231
$this->clearEnv();
232232

233-
$yamlenv = new Yamlenv($this->fixturesFolder, 'quoted.yaml');
233+
$yamlenv = new Yamlenv($this->fixturesFolder, 'quoted.yml');
234234
$yamlenv->load();
235235
$this->assertSame('no space', getenv('QWHITESPACE'));
236236
}
@@ -240,7 +240,7 @@ public function testYamlenvLoadDoesNotOverwriteEnv()
240240
$this->clearEnv();
241241

242242
putenv('IMMUTABLE=true');
243-
$yamlenv = new Yamlenv($this->fixturesFolder, 'immutable.yaml');
243+
$yamlenv = new Yamlenv($this->fixturesFolder, 'immutable.yml');
244244
$yamlenv->load();
245245

246246
$this->assertSame('true', getenv('IMMUTABLE'));
@@ -251,7 +251,7 @@ public function testYamlenvLoadAfterOverload()
251251
$this->clearEnv();
252252

253253
putenv('IMMUTABLE=true');
254-
$yamlenv = new Yamlenv($this->fixturesFolder, 'immutable.yaml');
254+
$yamlenv = new Yamlenv($this->fixturesFolder, 'immutable.yml');
255255
$yamlenv->overload();
256256
$this->assertSame('false', getenv('IMMUTABLE'));
257257

@@ -265,7 +265,7 @@ public function testYamlenvOverloadAfterLoad()
265265
$this->clearEnv();
266266

267267
putenv('IMMUTABLE=true');
268-
$yamlenv = new Yamlenv($this->fixturesFolder, 'immutable.yaml');
268+
$yamlenv = new Yamlenv($this->fixturesFolder, 'immutable.yml');
269269
$yamlenv->load();
270270
$this->assertSame('true', getenv('IMMUTABLE'));
271271

@@ -278,7 +278,7 @@ public function testYamlenvOverloadDoesOverwriteEnv()
278278
{
279279
$this->clearEnv();
280280

281-
$yamlenv = new Yamlenv($this->fixturesFolder, 'mutable.yaml');
281+
$yamlenv = new Yamlenv($this->fixturesFolder, 'mutable.yml');
282282
$yamlenv->overload();
283283
$this->assertSame('true', getenv('MUTABLE'));
284284
}
@@ -287,7 +287,7 @@ public function testYamlenvAllowsSpecialCharacters()
287287
{
288288
$this->clearEnv();
289289

290-
$yamlenv = new Yamlenv($this->fixturesFolder, 'specialchars.yaml');
290+
$yamlenv = new Yamlenv($this->fixturesFolder, 'specialchars.yml');
291291
$yamlenv->load();
292292
$this->assertSame('$a6^C7k%zs+e^.jvjXk', getenv('SPVAR1'));
293293
$this->assertSame('?BUty3koaV3%GA*hMAwH}B', getenv('SPVAR2'));
@@ -300,7 +300,7 @@ public function testYamlenvConvertsToUppercase()
300300
{
301301
$this->clearEnv();
302302

303-
$yamlenv = new Yamlenv($this->fixturesFolder, 'lowercase.yaml', true);
303+
$yamlenv = new Yamlenv($this->fixturesFolder, 'lowercase.yml', true);
304304
$yamlenv->load();
305305

306306
$validator = $yamlenv->required([
@@ -320,7 +320,7 @@ public function testYamlenvFailsIfNotConvertedToUppercase()
320320
{
321321
$this->clearEnv();
322322

323-
$yamlenv = new Yamlenv($this->fixturesFolder, 'lowercase.yaml', false);
323+
$yamlenv = new Yamlenv($this->fixturesFolder, 'lowercase.yml', false);
324324
$yamlenv->load();
325325

326326
$yamlenv->required([
@@ -334,7 +334,7 @@ public function testYamlenvAssertions()
334334
{
335335
$this->clearEnv();
336336

337-
$yamlenv = new Yamlenv($this->fixturesFolder, 'assertions.yaml');
337+
$yamlenv = new Yamlenv($this->fixturesFolder, 'assertions.yml');
338338
$yamlenv->load();
339339
$this->assertSame('val1', getenv('ASSERTVAR1'));
340340
$this->assertEmpty(getenv('ASSERTVAR2'));
@@ -373,7 +373,7 @@ public function testYamlenvEmptyThrowsRuntimeException()
373373
{
374374
$this->clearEnv();
375375

376-
$yamlenv = new Yamlenv($this->fixturesFolder, 'assertions.yaml');
376+
$yamlenv = new Yamlenv($this->fixturesFolder, 'assertions.yml');
377377
$yamlenv->load();
378378
$this->assertEmpty(getenv('ASSERTVAR2'));
379379

@@ -388,7 +388,7 @@ public function testYamlenvStringOfSpacesConsideredEmpty()
388388
{
389389
$this->clearEnv();
390390

391-
$yamlenv = new Yamlenv($this->fixturesFolder, 'assertions.yaml');
391+
$yamlenv = new Yamlenv($this->fixturesFolder, 'assertions.yml');
392392
$yamlenv->load();
393393
$this->assertEmpty(getenv('ASSERTVAR3'));
394394

@@ -403,7 +403,7 @@ public function testYamlenvHitsLastChain()
403403
{
404404
$this->clearEnv();
405405

406-
$yamlenv = new Yamlenv($this->fixturesFolder, 'assertions.yaml');
406+
$yamlenv = new Yamlenv($this->fixturesFolder, 'assertions.yml');
407407
$yamlenv->load();
408408
$yamlenv->required('ASSERTVAR3')->notEmpty();
409409
}
@@ -416,7 +416,7 @@ public function testYamlenvValidateRequiredWithoutLoading()
416416
{
417417
$this->clearEnv();
418418

419-
$yamlenv = new Yamlenv($this->fixturesFolder, 'assertions.yaml');
419+
$yamlenv = new Yamlenv($this->fixturesFolder, 'assertions.yml');
420420
$yamlenv->required('foo');
421421
}
422422

File renamed without changes.

0 commit comments

Comments
 (0)