|
| 1 | +# A .env replacement for storing secret credentials in your Laravel application |
| 2 | + |
| 3 | +[](https://packagist.org/packages/beyondcode/laravel-credentials) |
| 4 | +[](https://travis-ci.org/beyondcode/laravel-credentials) |
| 5 | +[](https://scrutinizer-ci.com/g/beyondcode/laravel-credentials) |
| 6 | +[](https://packagist.org/packages/beyondcode/laravel-credentials) |
| 7 | + |
| 8 | +The `beyondcode/laravel-credentials` package allows you to store all your secret credentials in an encrypted file and put that file into version control instead of |
| 9 | +having to add multiple credentials into your `.env` file. |
| 10 | + |
| 11 | +There are a couple of benefits of using encrypted credentials instead of environment keys: |
| 12 | + |
| 13 | +* Your credentials are encrypted. No one will be able to read your credentials without the key. |
| 14 | +* The encrypted credentials are saved in your repository. You'll have a history of the changes and who made them. |
| 15 | +* You can deploy credentials together with your code. |
| 16 | +* All secrets are in one location. Instead of managing multiple environment variables, everything is in one file. |
| 17 | + |
| 18 | +Here's how you can access your stored credentials: |
| 19 | + |
| 20 | +```php |
| 21 | +$secret = credentials('my-secret-credentials'); |
| 22 | +``` |
| 23 | + |
| 24 | +With the built-in edit command, you can easily edit your existing credentials. They will be automatically encrypted after saving your changes. |
| 25 | + |
| 26 | +```bash |
| 27 | +php artisan credentials:edit |
| 28 | +``` |
| 29 | + |
| 30 | + |
| 31 | + |
| 32 | +## Installation |
| 33 | + |
| 34 | +You can install the package via composer: |
| 35 | + |
| 36 | +```bash |
| 37 | +composer require beyondcode/laravel-credentials |
| 38 | +``` |
| 39 | + |
| 40 | +The package will automatically register itself. |
| 41 | + |
| 42 | +You can optionally publish the configuration with: |
| 43 | + |
| 44 | +```bash |
| 45 | +php artisan vendor:publish --provider="BeyondCode\Credentials\CredentialsServiceProvider" --tag="config" |
| 46 | +``` |
| 47 | + |
| 48 | +This is the content of the published config file: |
| 49 | + |
| 50 | +```php |
| 51 | +<?php |
| 52 | + |
| 53 | +return [ |
| 54 | + |
| 55 | + /* |
| 56 | + * Defines the file that will be used to store and retrieve the credentials. |
| 57 | + */ |
| 58 | + 'file' => config_path('credentials.php.enc'), |
| 59 | + |
| 60 | + /* |
| 61 | + * Defines the key that will be used to encrypt / decrypt the credentials. |
| 62 | + * The default is your application key. Be sure to keep this key secret! |
| 63 | + */ |
| 64 | + 'key' => config('app.key'), |
| 65 | + |
| 66 | + 'cipher' => config('app.cipher'), |
| 67 | + |
| 68 | +]; |
| 69 | +``` |
| 70 | + |
| 71 | +### Testing |
| 72 | + |
| 73 | +``` bash |
| 74 | +composer test |
| 75 | +``` |
| 76 | + |
| 77 | +### Changelog |
| 78 | + |
| 79 | +Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently. |
| 80 | + |
| 81 | +## Contributing |
| 82 | + |
| 83 | +Please see [CONTRIBUTING](CONTRIBUTING.md) for details. |
| 84 | + |
| 85 | +### Security |
| 86 | + |
| 87 | +If you discover any security related issues, please email marcel@beyondco.de instead of using the issue tracker. |
| 88 | + |
| 89 | +## Credits |
| 90 | + |
| 91 | +- [Marcel Pociot](https://github.com/mpociot) |
| 92 | +- [All Contributors](../../contributors) |
| 93 | + |
| 94 | +## License |
| 95 | + |
| 96 | +The MIT License (MIT). Please see [License File](LICENSE.md) for more information. |
0 commit comments