PHPackages                             beyondcode/laravel-credentials - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Security](/categories/security)
4. /
5. beyondcode/laravel-credentials

AbandonedArchivedLibrary[Security](/categories/security)

beyondcode/laravel-credentials
==============================

Store and access encrypted credentials in your Laravel application.

1.5.0(5y ago)577142.6k↓39.6%41[1 issues](https://github.com/beyondcode/laravel-credentials/issues)[5 PRs](https://github.com/beyondcode/laravel-credentials/pulls)2MITPHPPHP ^7.1

Since May 15Pushed 2y ago8 watchersCompare

[ Source](https://github.com/beyondcode/laravel-credentials)[ Packagist](https://packagist.org/packages/beyondcode/laravel-credentials)[ Docs](https://github.com/beyondcode/laravel-credentials)[ RSS](/packages/beyondcode-laravel-credentials/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (6)Dependencies (3)Versions (7)Used By (2)

Add encrypted credentials to your Laravel production environment
================================================================

[](#add-encrypted-credentials-to-your-laravel-production-environment)

[![Latest Version on Packagist](https://camo.githubusercontent.com/fd82bec1cabb0a1254dd915c890776cbaa1bfa89d5a691b813280dd0b6205f1e/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6265796f6e64636f64652f6c61726176656c2d63726564656e7469616c732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/beyondcode/laravel-credentials)[![Build Status](https://camo.githubusercontent.com/777387b13d07759b25a753bf4e07c274ab9257855ab52a050173566484550520/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f6265796f6e64636f64652f6c61726176656c2d63726564656e7469616c732f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/beyondcode/laravel-credentials)[![Quality Score](https://camo.githubusercontent.com/26c4b77f9d12d99bfef9b63dd9d73e38148329bcbaf2951ca78075ea08093265/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f6265796f6e64636f64652f6c61726176656c2d63726564656e7469616c732e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/beyondcode/laravel-credentials)[![Total Downloads](https://camo.githubusercontent.com/1827218b9ab164aa0ae5d76948566b279dfa1cc4c0835f1ab3492e2340251a53/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6265796f6e64636f64652f6c61726176656c2d63726564656e7469616c732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/beyondcode/laravel-credentials)

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 having to add multiple credentials into your `.env` file in your production environment.

There are a couple of benefits of using encrypted credentials instead of environment keys:

- Your credentials are encrypted. No one will be able to read your credentials without the key.
- The encrypted credentials are saved in your repository. You'll have a history of the changes and who made them.
- You can deploy credentials together with your code.
- All secrets are in one location. Instead of managing multiple environment variables, everything is in one file.

Here's how you can access your stored credentials. In this example we're retrieving the decrypted credential for the key `api-password`:

```
$credential = credentials('api-password');
```

You can also specify a fallback value to be used if the credential for the specified key cannot be decrypted:

```
$credential = credentials('my-production-token', 'my-fallback-value');
```

With the built-in edit command, you can easily edit your existing credentials. They will be automatically encrypted after saving your changes.

```
php artisan credentials:edit
```

Optionally, you can change the used editor by adding the following to your .env file:

```
EDITOR=nano

```

[![Credentials Demo](https://camo.githubusercontent.com/27b1e26e5c353894076d661b2b941e45e4111bf33d96a4798892f25ea588156b/68747470733a2f2f6265796f6e64636f2e64652f6769746875622f63726564656e7469616c732e676966)](https://camo.githubusercontent.com/27b1e26e5c353894076d661b2b941e45e4111bf33d96a4798892f25ea588156b/68747470733a2f2f6265796f6e64636f2e64652f6769746875622f63726564656e7469616c732e676966)

Installation
------------

[](#installation)

You can install the package via composer:

```
composer require beyondcode/laravel-credentials
```

The package will automatically register itself.

You can optionally publish the configuration with:

```
php artisan vendor:publish --provider="BeyondCode\Credentials\CredentialsServiceProvider" --tag="config"
```

This is the content of the published config file:

```
