• Stars
    star
    168
  • Rank 225,507 (Top 5 %)
  • Language
    PHP
  • License
    MIT License
  • Created over 9 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Interact with a .env file from the command line.

WP-CLI Dotenv Command

Travis Build Packagist

NAME

  wp dotenv

DESCRIPTION

  Manage a .env file

SYNOPSIS

  wp dotenv <command>

SUBCOMMANDS

  delete      Delete a definition from the environment file
  get         Get the value for a given key from the environment file
  init        Initialize the environment file
  list        List the defined variables from the environment file
  salts       Manage WordPress salts in .env format
  set         Set a value in the environment file for a given key.

All dotenv commands accept a --file=<path> parameter to specify the location of the environment file.
Defaults to .env.
If used, this parameter can be an absolute or relative path to the environment file, but which must include the file name (it does not have to be .env).

init

Initializes a new environment file.

By default, this command will only create the environment file if it does not already exist, but it can do much more.

--template=<file>

You may optionally initialize the environment file using another file as a template (eg: .env.example, a common convention). Run wp dotenv init --template=.env.example to use that file as the basis for the new environment file.

By default, the new file will be a copy of the template, but you may also set new values on the fly interactively! Passing the --interactive flag with the same command will prompt for each defined variable in the template. You may specify a new value to use, or simply leave it blank to keep the template-defined value. Any other lines/comments from the template are preserved.

--with-salts

Initialize the new environment file with fresh salts provided by the wordpress.org salt generator service. Any existing keys by the same name will not be overwritten. See salts.

--force

Overwrites an existing environment file, if it exists.

list [<pattern>...]

Prints out all of the key/value pairs as defined in the environment file.

You may also optionally limit the output to specific keys, or even keys that match simple patterns using glob pattern syntax. Eg: wp dotenv list DB_* *AWS* would produce a list with the following hypotheical keys:

DB_NAME=...
DB_PASS=...
S3_AWS_ID=...
S3_AWS_SECRET=...

The list command supports all of the same options for --format=<out> you've known to grow and love (table,json,csv,..etc). Default: table.

get <key>

Get the value of a defined key from the environment file.

set <key> <value>

Set the value of a key in the environment file.

By default the value that is set is not quoted in the file. If you need your value to be quoted a certain way, you may optionally pass a flag for the preferred style of quote you want: --quote-single or --quote-double.

delete <key>...

Remove one or more definitions for the given keys from the environment file.

salts

generate

Adds variable definitions to the environment file with fresh salts provided by the wordpress.org salt generator service.

By default, any existing keys by the same name will not be overwritten. However, if all of the defined salts in the environment file have the same value, then it is assumed that they are placeholders and will be updated. It is also possible to force regenerate them using --force, or simply use the regenerate command (see below).

regenerate

Same as generate, but will update all keys for salts with new values.

Installation

Recommended

As of WP-CLI v0.23, you may install the dotenv command using the new package command:

wp package install aaemnnosttv/wp-cli-dotenv-command:^2.0

For installation with prior versions of WP-CLI, see the wiki.

That's it! Now you should see the dotenv command as an option when you run wp from any directory.

More Repositories

1

wp-sqlite-db

A single file drop-in for using a SQLite database with WordPress. Based on the original SQLite Integration plugin.
PHP
491
star
2

wp-cli-valet-command

Harness the power of Laravel Valet for creating fully functional WordPress installs in seconds.
PHP
286
star
3

wp-cli-login-command

Log in to WordPress with secure passwordless magic links.
PHP
268
star
4

silk

A modern API for WordPress.
PHP
67
star
5

valet-dashboard

A simple dashboard for Laravel Valet to display all available sites.
PHP
22
star
6

version-assets

A WordPress plugin to automatically apply a content-based version on all of your assets to optimize browser caching.
PHP
15
star
7

wp-plugin-activation-manifest

PHP
11
star
8

wp-sqlite-integration

PHP
10
star
9

silk-docs

Silk Documentation. For API docs, see here: https://api.silk.aaemnnost.tv/master/
9
star
10

wordpress-tests-core

This project is deprecated. See WP PHPUnit! ->>>>
PHP
9
star
11

boiler

A WordPress plugin boilerplate
Shell
7
star
12

last-modified-timestamp

A WordPress plugin for making the last modified date/time more accessible.
PHP
6
star
13

wp-cli-media-generate-command

A WP-CLI Command for generating media items and importing them into the media library.
PHP
5
star
14

quick-tab-switcher

Browser extension for switching tabs in a flash, without leaving the keyboard.
JavaScript
5
star
15

purity

A conflict-free utility library.
PHP
5
star
16

bedrock-valet-driver

Laravel Valet Driver for the Roots Bedrock WordPress application project boilerplate
PHP
4
star
17

pagelines

PageLines Framework 2.X made updateable with https://github.com/afragen/github-updater
PHP
4
star
18

wp-cli-http-command

WP-CLI command for using the WordPress HTTP API
PHP
4
star
19

wpenv

Environment-specific control for WordPress installs
PHP
4
star
20

wp-cli-login-server

[READ ONLY] Subtree split of wp-cli-login-command server plugin. (See aaemnnosttv/wp-cli-login-command)
PHP
4
star
21

post-link-shortcodes

A collection of shortcodes for building links, images, or URLs to a given post/archive of any type.
PHP
3
star
22

html5-analytics

Dead-simple Google Analytics event tracking using HTML5 data attributes
JavaScript
2
star
23

gskbuild

Shell
2
star
24

War.php

A high-performance engine for playing the card game of War.
PHP
2
star
25

bedrock-mailtrap

A Mailtrap plugin for Roots Bedrock.
PHP
2
star
26

silk-plugin

Silk: The WordPress plugin.
PHP
1
star
27

webgloss

A toy glossary app, using Laravel, Vue.js, and Bootstrap 4
PHP
1
star
28

pagelines-developer

A plugin for pagelines developers developers developers
CSS
1
star
29

wp-env-auto-privacy

A WordPress plugin for (trying to) ensure that non-production sites are not indexed by search engines.
PHP
1
star
30

deprecated-hooks

PHP
1
star
31

shortcode-alias-api

A WordPress plugin for providing an API to create powerful shortcode aliases.
PHP
1
star
32

nag-squelcher

Shush with the nagging!
PHP
1
star
33

docker-sage-build

A docker container for running the Roots Sage theme build.
1
star