Download the PHP package roots/wp-config without Composer

On this page you can find all versions of the php package roots/wp-config. 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 wp-config

wp-config

Build Status Packagist Downloads Follow Roots Sponsor Roots

Fluent configuration management for WordPress

Support us

Roots is an independent open source org, supported only by developers like you. Your sponsorship funds WP Packages and the entire Roots ecosystem, and keeps them independent. Support us by purchasing Radicle or sponsoring us on GitHub — sponsors get access to our private Discord.

Requirements

Installation

Usage

Basic configuration

Conditional configuration

Accessing values

Environment variables

The Config class includes built-in support for loading environment variables:

Hook system

The Config class includes an instance-scoped hook system for extensible configuration:

Automatic before_apply hook

The Config class automatically executes any before_apply hooks when apply() is called. This enables packages to register configuration logic that runs automatically without requiring manual hook calls:

Upgrading from v1

Step 1: Update composer.json

Step 2: Replace static calls

Before:

After:

Step 3: Consolidate environment files

Before:

After:

Step 4: Update environment loading

Before:

After:

Step 5: Update hook usage

Hooks are now instance methods instead of static methods:

Before:

After:

Removed APIs

API reference

Config class

__construct(string $rootDir)

Creates a new Config instance with the specified root directory.

make(string $rootDir): static

Creates a new Config instance with a fluent-friendly named constructor.

bootstrapEnv(): self

Loads environment variables from .env files.

set(string|array $key, mixed $value = null): self

Sets a configuration value. Accepts a key/value pair or an associative array. Overwrites existing config map entries. Throws ConstantAlreadyDefinedException if a PHP constant with that name already exists.

env(string|array $key, mixed $default = null): self

Sets a configuration value from an environment variable. Falls back to $default if the variable is not set.

get(string $key, mixed $default = null): mixed

Gets a configuration value. Returns $default if the key is not set and a default is provided. Throws UndefinedConfigKeyException if the key is not set and no default is provided.

when(bool|Closure $condition, callable $callback): self

Conditionally executes configuration logic. The condition can be a boolean or a Closure that receives the Config instance.

apply(): void

Applies all configuration values by defining constants. Automatically runs before_apply hooks first.

addAction(string $tag, callable $callback, int $priority = 10): self

Adds a hook callback that can be executed later with doAction(). Returns $this for chaining.

doAction(string $tag, ...$args): self

Executes all callbacks registered for the specified hook. Returns $this for chaining.

Exceptions

Full example

A complete Bedrock-style application.php configuration file:

Community

Keep track of development and community news.


All versions of wp-config with dependencies

PHP Build Version
Package Version
Requires php Version >=8.3
vlucas/phpdotenv Version ^5.6
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 roots/wp-config contains the following files

Loading the files please wait ...