Skip to content

Commit 52970ff

Browse files
committed
Initial commit
1 parent 72280d5 commit 52970ff

14 files changed

+11718
-22
lines changed

.gitignore

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,3 @@
11
/vendor/
2-
node_modules/
3-
npm-debug.log
4-
yarn-error.log
5-
6-
# Laravel 4 specific
7-
bootstrap/compiled.php
8-
app/storage/
9-
10-
# Laravel 5 & Lumen specific
11-
public/storage
12-
public/hot
13-
14-
# Laravel 5 & Lumen specific with changed public path
15-
public_html/storage
16-
public_html/hot
17-
18-
storage/*.key
19-
.env
20-
Homestead.yaml
21-
Homestead.json
22-
/.vagrant
2+
.idea
233
.phpunit.result.cache

.php-cs-fixer.php

Lines changed: 165 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,165 @@
1+
<?php
2+
// https://gist.github.com/laravel-shift/cab527923ed2a109dda047b97d53c200#gistcomment-3755709
3+
4+
// https://cs.symfony.com/doc/rules/index.html
5+
$rules = [
6+
'array_syntax' => ['syntax' => 'short'],
7+
8+
'blank_line_after_namespace' => true,
9+
'blank_line_after_opening_tag' => true,
10+
'braces' => true,
11+
'cast_spaces' => true,
12+
'concat_space' => [
13+
'spacing' => 'one',
14+
],
15+
'declare_equal_normalize' => true,
16+
'elseif' => true,
17+
'encoding' => true,
18+
'full_opening_tag' => true,
19+
'fully_qualified_strict_types' => true, // added by Shift
20+
'function_declaration' => true,
21+
'function_typehint_space' => true,
22+
'heredoc_to_nowdoc' => true,
23+
'include' => true,
24+
'increment_style' => ['style' => 'post'],
25+
'indentation_type' => true,
26+
'linebreak_after_opening_tag' => true,
27+
'line_ending' => true,
28+
'lowercase_cast' => true,
29+
'lowercase_keywords' => true,
30+
'lowercase_static_reference' => true, // added from Symfony
31+
'magic_method_casing' => true, // added from Symfony
32+
'magic_constant_casing' => true,
33+
'method_argument_space' => true,
34+
'native_function_casing' => true,
35+
'no_alias_functions' => true,
36+
'no_extra_blank_lines' => [
37+
'tokens' => [
38+
'extra',
39+
'throw',
40+
'use'
41+
],
42+
],
43+
'no_blank_lines_after_class_opening' => true,
44+
'no_blank_lines_after_phpdoc' => true,
45+
'no_closing_tag' => true,
46+
'no_empty_phpdoc' => true,
47+
'no_empty_statement' => true,
48+
'no_leading_import_slash' => true,
49+
'no_leading_namespace_whitespace' => true,
50+
'no_mixed_echo_print' => [
51+
'use' => 'echo',
52+
],
53+
'no_multiline_whitespace_around_double_arrow' => true,
54+
'multiline_whitespace_before_semicolons' => [
55+
'strategy' => 'no_multi_line',
56+
],
57+
'no_short_bool_cast' => true,
58+
'no_singleline_whitespace_before_semicolons' => true,
59+
'no_spaces_after_function_name' => true,
60+
'no_spaces_inside_parenthesis' => true,
61+
'no_trailing_comma_in_singleline' => true,
62+
'no_trailing_whitespace' => true,
63+
'no_trailing_whitespace_in_comment' => true,
64+
'no_unreachable_default_argument_value' => true,
65+
'no_useless_return' => true,
66+
'no_whitespace_before_comma_in_array' => true,
67+
'no_whitespace_in_blank_line' => true,
68+
'normalize_index_brace' => true,
69+
'not_operator_with_successor_space' => false,
70+
'object_operator_without_whitespace' => true,
71+
'phpdoc_indent' => true,
72+
'phpdoc_no_access' => true,
73+
'phpdoc_no_package' => true,
74+
'phpdoc_no_useless_inheritdoc' => true,
75+
'phpdoc_scalar' => true,
76+
'phpdoc_single_line_var_spacing' => true,
77+
'phpdoc_summary' => true,
78+
'phpdoc_to_comment' => true,
79+
'phpdoc_trim' => true,
80+
'phpdoc_types' => true,
81+
'phpdoc_var_without_name' => true,
82+
'self_accessor' => true,
83+
'short_scalar_cast' => true,
84+
'simplified_null_return' => false, // disabled by Shift
85+
'single_blank_line_at_eof' => true,
86+
'single_blank_line_before_namespace' => true,
87+
'single_import_per_statement' => true,
88+
'single_line_after_imports' => true,
89+
'single_line_comment_style' => [
90+
'comment_types' => ['hash'],
91+
],
92+
'single_quote' => true,
93+
'space_after_semicolon' => true,
94+
'standardize_not_equals' => true,
95+
'switch_case_semicolon_to_colon' => true,
96+
'switch_case_space' => true,
97+
'ternary_operator_spaces' => true,
98+
'trim_array_spaces' => true,
99+
'unary_operator_spaces' => true,
100+
'whitespace_after_comma_in_array' => true,
101+
102+
// php-cs-fixer 3: Renamed rules
103+
'constant_case' => ['case' => 'lower'],
104+
'general_phpdoc_tag_rename' => true,
105+
'phpdoc_inline_tag_normalizer' => true,
106+
'phpdoc_tag_type' => true,
107+
'psr_autoloading' => true,
108+
'trailing_comma_in_multiline' => false,
109+
110+
// php-cs-fixer 3: Changed options
111+
'binary_operator_spaces' => [
112+
'default' => 'single_space',
113+
'operators' => ['=>' => null],
114+
],
115+
'blank_line_before_statement' => [
116+
'statements' => ['return'],
117+
],
118+
'class_attributes_separation' => [
119+
'elements' => [
120+
'const' => 'one',
121+
'method' => 'one',
122+
'property' => 'one',
123+
],
124+
],
125+
'class_definition' => [
126+
'multi_line_extends_each_single_line' => true,
127+
'single_item_single_line' => true,
128+
'single_line' => true,
129+
],
130+
'ordered_imports' => [
131+
'sort_algorithm' => 'alpha',
132+
],
133+
134+
// php-cs-fixer 3: Removed rootless options (*)
135+
'no_unneeded_control_parentheses' => [
136+
'statements' => ['break', 'clone', 'continue', 'echo_print', 'return', 'switch_case', 'yield'],
137+
],
138+
'no_spaces_around_offset' => [
139+
'positions' => ['inside', 'outside'],
140+
],
141+
'visibility_required' => [
142+
'elements' => ['property', 'method', 'const'],
143+
],
144+
145+
];
146+
147+
$finder = PhpCsFixer\Finder::create()
148+
->in([
149+
__DIR__.'/app',
150+
__DIR__.'/config',
151+
__DIR__.'/database',
152+
__DIR__.'/resources',
153+
__DIR__.'/routes',
154+
__DIR__.'/tests',
155+
])
156+
->name('*.php')
157+
->notName('*.blade.php')
158+
->ignoreDotFiles(true)
159+
->ignoreVCS(true);
160+
161+
return (new PhpCsFixer\Config())
162+
->setFinder($finder)
163+
->setRules($rules)
164+
->setRiskyAllowed(true)
165+
->setUsingCache(true);

README.md

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,35 @@
11
# laravel-env-in-aws-ssm
2-
Manage your environment variables in in AWS' SSM Parameter store
2+
> Manage your environment variables in in AWS' SSM Parameter store
3+
4+
Download or upload your .env files into the free [AWS's SSM](https://eu-west-2.console.aws.amazon.com/systems-manager/parameters) store. This allows you to store up to 10,000 keys with sizes up to 4kb. More advanced options are available subject to your [quota](https://docs.aws.amazon.com/general/latest/gr/ssm.html).
5+
6+
This provides a good companion to referencing env values in cloudformation, serverless framework or to download within runners in other forms of Continuous Deployment processes.
7+
8+
```shell
9+
composer require nandi95/laravel-env-in-aws-ssm
10+
```
11+
12+
This package provides two commands:
13+
```shell
14+
php artisan env:push
15+
php artisan env:pull
16+
```
17+
18+
### Arguments:
19+
- `stage` - this is something the equivalent of `production|staging|develop|...`) which identifies what environment the variables are used in.
20+
21+
- `--appName=`(optional) - this is the name of the current app (equivalent the APP_NAME in the `.env` file normally). If not given, or cannot be found, it will prompt the user for it.
22+
23+
- `--secretKey=`(optional) - The secret key for the user with the required permissions. If not given, or cannot be found, it will prompt the user for it.
24+
25+
- `--accessKey=`(optional) - The access key id for the user with the required permissions. If not given, or cannot be found, it will prompt the user for it.
26+
27+
- `--region=`(optional) - The region the infrastructure resides in. If not given, or cannot be found, it will prompt the user for it.
28+
29+
---
30+
31+
Both commands will use the env file respective to the stage argument. For example: with stage argument `production` it will work with the `.env.production` file. If the file exists when pulling, it will back up the existing file.
32+
33+
### Parameter <-> environment variable
34+
Keys are transformed in the following manner:
35+
`DB_PASSWORD` => `{appName}/{stage}/DB_PASSWORD`

composer.json

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
{
2+
"name": "nandi95/laravel-env-in-aws-ssm",
3+
"version": "0.1.0",
4+
"description": "Manage your environment variables in in AWS' SSM Parameter store",
5+
"type": "library",
6+
"license": "MIT",
7+
"autoload": {
8+
"psr-4": {
9+
"Nandi95\\LaravelEnvInAwsSsm\\": "src/"
10+
}
11+
},
12+
"extra": {
13+
"laravel": {
14+
"providers": [
15+
"Nandi95\\LaravelEnvInAwsSsm\\EnvInAwsSsmServiceProvider"
16+
]
17+
}
18+
},
19+
"authors": [
20+
{
21+
"name": "Nandor Kraszlan",
22+
"email": "[email protected]"
23+
}
24+
],
25+
"minimum-stability": "stable",
26+
"require-dev": {
27+
"php": ">=8.0",
28+
"orchestra/testbench": "^7.0",
29+
"phpunit/phpunit": "^9.5",
30+
"roave/security-advisories": "dev-latest",
31+
"friendsofphp/php-cs-fixer": "^3.11",
32+
"phpmd/phpmd": "^2.13",
33+
"phpro/grumphp": "^1.13",
34+
"nunomaduro/larastan": "^2.2"
35+
},
36+
"require": {
37+
"aws/aws-sdk-php": "^3.235",
38+
"symfony/dotenv": "^6.1"
39+
},
40+
"config": {
41+
"allow-plugins": {
42+
"phpro/grumphp": true
43+
}
44+
},
45+
"scripts": {
46+
"post-update-cmd": [
47+
"Scripts\\ComposerScripts::devModeOnly",
48+
"@php ./vendor/bin/grumphp git:init"
49+
],
50+
"sniff": [
51+
"./vendor/bin/php-cs-fixer fix -vvv --dry-run --show-progress=dots"
52+
],
53+
"lint": [
54+
"./vendor/bin/php-cs-fixer fix -vv --show-progress=dots"
55+
],
56+
"phpstan": [
57+
"./vendor/bin/phpstan analyse --memory-limit=2G"
58+
],
59+
"php-md": [
60+
"./vendor/bin/phpmd src ansi ./phpmd-ruleset.xml"
61+
]
62+
}
63+
}

0 commit comments

Comments
 (0)