Download the PHP package mnapoli/dotlock without Composer

On this page you can find all versions of the php package mnapoli/dotlock. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package dotlock

The problem

Some projects need secrets to work locally: an OpenAI key, a Stripe test key, a sandbox API token password…

They sit in .env or ~/.bashrc in plain text. Every process on your machine can read them: a malicious dependency, a rogue agent, a compromised application.

The solution

Dotlock moves secrets to .env.secrets, a gitignored file that looks like .env but the values are encrypted with a passphrase you choose:

Now run php artisan dev:

Dotlock prompts for your passphrase, decrypts the values, and the usual Laravel dev processes start with the secrets in their environment variables. Secrets are never written to disk.

Laravel then runs as usual. Nothing else in the application changes.

[!NOTE] Dotlock works with php artisan dev, it doesn't work with Herd or Valet. Their PHP-FPM is started by the OS, not by your shell, so we cannot inject the secrets into their environment.

Install

Add this at the top of bootstrap/app.php, before Application::configure():

Then add the file to .gitignore:

You could commit it to share the secrets with teammates, but you'd have to share the passphrase and everyone would share the same secrets.

Usage

Import a secret from .env or add a new one:

If the secret was already in .env, it is moved to .env.secrets. The passphrase is your password that unlocks everything, it is never stored anywhere, remember it!

Leave non-secret environment variables in .env, .env.secrets is only for secrets.

Start working:

Other commands:

Command
secrets:list List the secret names, not the values
secrets:get NAME Retrieve a secret value
secrets:forget NAME Forget a secret
secrets:rekey Change the passphrase without rewriting a single value

For non-interactive use (scripts, a shell you trust…), export the passphrase in APP_SECRETS_KEY (every artisan command unlocks the secrets automatically):

You can also read it from your password manager rather than typing it into shell history, e.g. with 1Password:

Limits

How it works

Alternatives

php artisan env:encrypt

It encrypts the whole .env into .env.encrypted meant to be committed and decrypted on deploy. It solves prod secrets, not your local machine: to use it you run env:decrypt, and the plaintext .env is back on disk. Dotlock encrypts value by value, keeps the names readable, and the decrypted values only ever exist in process memory.

1Password CLI

In theory, you could set API_TOKEN="$(op read op://Private/my-app/token)" in .env, but that doesn't work out of the box (.env files are parsed, not executed). To make it work, you have to wrap every command with op run (op is the 1Password CLI). For example op run --env-file .env -- php artisan tinker. This is a pain to remember and type. On top of that, some values live in .env and some in the 1Password vault, which is not the best DX.

Apple Keychain

The Apple Keychain has a CLI to read secrets, but it is macOS-only and has no integration with .env or Laravel. You'd have to run commands like API_TOKEN="$(security find-generic-password -s my-app -a api-token -w)" php artisan tinker. And secrets stored this way can be read back silently by any process running as your user, the Keychain doesn't prompt when a malicious script shells out to the same command.


All versions of dotlock with dependencies

PHP Build Version
Package Version
Requires php Version ^8.4
ext-sodium Version *
laravel/framework Version ^13.0
laravel/prompts Version ^0.3
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package mnapoli/dotlock contains the following files

Loading the files please wait ...