PHPackages                             devuri/wp-env-app - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. devuri/wp-env-app

Abandoned → [devuri/wpframework](/?search=devuri%2Fwpframework)ArchivedProject[Utility &amp; Helpers](/categories/utility)

devuri/wp-env-app
=================

A base WordPress project to create web applications using environment variables.

v0.8.0(2y ago)1152MITPHP

Since Mar 14Pushed 2y ago1 watchersCompare

[ Source](https://github.com/devuri/wp-env-app)[ Packagist](https://packagist.org/packages/devuri/wp-env-app)[ RSS](/packages/devuri-wp-env-app/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)Dependencies (23)Versions (38)Used By (0)

A Lightweight WordPress Project Framework
=========================================

[](#a-lightweight-wordpress-project-framework)

A lightweight framework for your next WordPress web application. This framework is focused on providing a well-organized structure, making it more straightforward to develop, deploy, and maintain WordPress websites and web applications.

> **Note**
>
> ⚠️ **Work in progress:** Please note: This framework is currently under active development. We welcome community involvement, so feel free to contribute via pull requests or by reporting issues.

Features
--------

[](#features)

- **Modular Structure**: Promotes a modular approach to WordPress development, allowing you to organize your code into separate modules or packages for better code organization and reusability.
- **Dependency Management**: With the help of Composer, allows you to manage your WordPress plugins, themes, and libraries effortlessly. It provides a composer.json file to easily include and update dependencies.
- **Environment Configuration**: Implements the concept of environment-specific configurations using the `.env` file. You can define environment variables for different environments (e.g., development, staging, production) to easily manage database connections, API keys, and other environment-specific settings.
- **Enhanced Security**: By moving sensitive files outside of the web root directory, it helps improve the security of your WordPress installation. Critical files are stored outside the public directory, preventing direct access.
- **Version Control Friendly**: Encourages the use of version control systems like Git. By separating core WordPress files from your project files, it makes it easier to manage and track changes to your custom code while excluding WordPress core files from version control.
- **Modern Development Workflow**: Embraces modern development practices, allowing you to use build tools like Webpack for asset management and build processes. You can easily integrate frontend frameworks or preprocessors into your project for an optimized development workflow.
- **Tenancy** introduces comprehensive [`multi-tenant`](https://devuri.github.io/wp-env-config/multi-tenant/) functionality starting from version 0.8.0, enabling the support of multiple tenants (websites) within a single environment. Each tenant benefits from its own dedicated database, configuration, and customization options, all while operating on a shared infrastructure. This design ensures maximum flexibility for tailoring solutions to meet specific requirements.

This WordPress App Framework is intended to provide a reliable solution for WordPress web application development, enhancing both efficiency and security. We invite the community to join us in refining and evolving this tool.

Requirements
------------

[](#requirements)

To use get started, make sure your environment meets the following requirements:

- PHP version 7.4 or higher
- Composer ()

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

[](#installation)

Run the following command in your terminal:

```
composer create-project devuri/wp-env-app blog
```

After the installation process, you will find a new `.env` file in your project directory. This file contains all the necessary environment variables.

### Configuration

[](#configuration)

Open the `.env` file in a text editor of your choice and make the following configurations:

- **DB\_NAME:** Set the name of your database.
- **DB\_USER:** Set the database user.
- **DB\_PASSWORD:** Set the database password.
- **DB\_HOST:** In most cases, this can remain as 'localhost' if you are using the default database host.

Update the **WP\_HOME** value with the correct URL for your application.

> The framework will automatically generate salts and set the **DB\_PREFIX**.

By default, the **BASIC\_AUTH\_USER** is set to `admin` and **BASIC\_AUTH\_PASSWORD** is set to `demo`. You can change these values to your preference if you intend to enable basic authentication.

```
WP_HOME='http://example.com'
WP_SITEURL="${WP_HOME}/wp"

BASIC_AUTH_USER='admin'
BASIC_AUTH_PASSWORD='demo'

USE_APP_THEME=false
WP_ENVIRONMENT_TYPE='debug'
BACKUP_PLUGINS=false

SENDGRID_API_KEY=''
SUDO_ADMIN='1'

MEMORY_LIMIT='256M'
MAX_MEMORY_LIMIT='256M'

FORCE_SSL_ADMIN=false
FORCE_SSL_LOGIN=false

DB_NAME=wp_dbName
DB_USER=root
DB_PASSWORD=
DB_HOST=localhost
DB_PREFIX=wp_wmrnhxag_
```

> Full list of [Environment Variables](https://devuri.github.io/wp-env-config/env/)

### Fresh WordPress Installation

[](#fresh-wordpress-installation)

Once all configuration is complete, you can execute the following command to set up a fresh WordPress installation:

```
php nino wp:install

```

Now you're ready to start using the framework with your customized configurations and a fresh WordPress installation.

> or

1. Clone or download the repository to your local development environment.
2. Install dependencies by running `composer install` in the project root directory.
3. Rename the `.env.example` file to `.env` and customize it according to your environment settings.
4. Set up your web server to point to the `public` directory as the document root.
5. Run the WordPress installation process through your web browser.
6. Start building your awesome WordPress project!

### Auto Login

[](#auto-login)

The framework supports auto login via the command-line interface (CLI) command `wp:login`. This command will provide you with a signed URL for logging in. It relies on the `WPENV_AUTO_LOGIN_SECRET_KEY` defined in the `.env` file.

To generate a new secret key, use the built-in `nino` CLI tool. Run the following command to create a new key:

```
php nino config loginkey

```

This will append a new key to your `.env` file. You can then safely remove the old key from the `.env` file.

After generating a new key, run the `php nino wp:login` command again to obtain a new login link using the updated key.

Folder Structure
----------------

[](#folder-structure)

Here's an overview of the directory structure used:

> You can also check out the basic version with unified directory structure [WordPress web app skeleton](https://github.com/devuri/wp-app-skeleton).

```
├── .snapshot           # New top-level directory for snapshots (replaces backups)
├── public              # Web server root directory
│   ├── app             # WordPress core files (excluded from version control)
│   │   ├── uploads     # WordPress uploads directory
│   │   ├── templates   # Custom themes directory
│   │   └── themes      # WordPress themes directory
│   ├── mu-plugins      # Must-use plugins directory
│   ├── plugins         # WordPress plugins directory
│   ├── wp              # WordPress core files (excluded from version control)
│   ├── .htaccess       # Web server configuration file
│   ├── index.php       # WordPress entry point [-r-r-r]
│   └── wp-config.php   # WordPress configuration file [-r-r-r]
├── pubkey              # Public key used for encryption or verification purposes
│   └── samplekey.pub   # Example key: b75b666f-ac11-4342-b001-d2546f1d3a5b.pub
├── storage             # Storage directory for cache and logs
│   ├── cache           # Cache directory
│   └── logs            # Logs directory
│       └── wp-errors   # WordPress error logs
├── vendor              # Composer dependencies directory
├── .env                # Environment configuration file
├── app.php             # Application configuration file
├── bootstrap.php       # Bootstrap file [-r-r-r]
├── composer.json       # Composer configuration file
└── config.php          # Project configuration file overrides framework constants.

```

Items marked `[-r-r-r]` should or can be set as `read-only`

> see [framework directory structure](https://devuri.github.io/wp-env-app/structure/)

Additional Customization
------------------------

[](#additional-customization)

wp-env-app allows for additional customization options. Here are some examples:

**Modify Web Root**: By default, the project web root is set to `public`. To change it to something other than `public`, edit `app.php` and `composer.json`. For example, if the web root is set as `public_html`, update the following sections:

> composer.json:

```
 "extra":{
    "wordpress-install-dir": "public_html/wp",
    "installer-paths": {
        "public_html/app/mu-plugins/{$name}/": [
            "type:wordpress-muplugin"
        ],
        "public_html/app/plugins/{$name}/": [
            "type:wordpress-plugin"
        ],
        "public_html/template/{$name}/": [
            "type:wordpress-theme"
        ]
    }
}
```

> app.php:

```
    return [
        'web_root'      => 'public_html', // web root is now set as public_html
        'content_dir'   => 'app',
        'plugin_dir'    => 'app/plugins',
        'mu_plugin_dir' => 'app/mu-plugins',
        'default_theme' => 'brisko',
    ];
```

Configuration
-------------

[](#configuration-1)

The `app.php` file contains various configuration options that you can customize based on your project requirements. Here's an overview of the available options:

- `web_root`: Sets the public web directory (default: `public`).
- `asset_dir`: Sets the global assets directory (default: `assets`).
- `content_dir`: Sets the content directory for the project (default: `app`).
- `plugin_dir`: Sets the directory for installing and managing plugins (default: `plugins`).
- `mu_plugin_dir`: Sets the directory for Must-Use (MU) plugins (default: `mu-plugins`).
- `sqlite_dir`: Sets the directory for the SQLite database (default: `sqlitedb`).
- `sqlite_file`: Sets the filename for the SQLite database (default: `.sqlite-wpdatabase`).
- `default_theme`: Sets the default fallback theme (default: `brisko`).
- `disable_updates`: Disables WordPress updates (default: `true`).
- `can_deactivate`: Controls whether plugins can be deactivated (default: `false`).
- `theme_dir`: Sets the directory for additional themes (default: `templates`).
- `error_handler`: Sets the error handler for the project (default: Symfony error handler).

> Feel free to modify these options as needed to fit your project's directory structure and requirements.
>
> Full list of [Configuration Options](https://devuri.github.io/wp-env-app/configuration/)

Errors
------

[](#errors)

The framework allows for the use of `oops` (whoops) or `Symfony` as the error handler.

By default, the Symfony error handler is used. To change the error handler, set the `error_handler` option to `oops`. To disable the error handlers completely, set the `error_handler` option to `null`.

> Please note that the error handler will only run in `debug`, `development`, or `local` environments.

.htaccess file for highspeed and security.
------------------------------------------

[](#htaccess-file-for-highspeed-and-security)

An ideal .htaccess configuration file for optimal speed and security is suitable for all WordPress websites with proven effectiveness. It has been rigorously tested on numerous websites to ensure both speed and security. In the event that you are operating a WordPress Multisite, adjustments should be made to the final section of this file.

> .htaccess configuration file:

Enhanced WordPress Installation Security
----------------------------------------

[](#enhanced-wordpress-installation-security)

Prevents the standard WordPress installation screen from appearing in specific environments for enhanced security.

#### Installation Security

[](#installation-security)

A 'WP is not installed' message will display in environments marked as 'secure,' 'sec,' 'production,' or 'prod.'

This change helps prevent unauthorized installations and takeovers, which can occur due to various reasons such as a disconnected database or table prefix changes.

To override this enhancement:

1. Open your `.env` file.
2. Set `WP_ENVIRONMENT_TYPE` explicitly to:
    - `staging`
    - `development`
    - `dev`
    - Or an appropriate value for your environment.

With this setup, your WordPress installation will be secure, and you won't risk unauthorized installations or takeovers.

Private Repository
------------------

[](#private-repository)

You can use the `auth.json` file to install private themes and plugins hosted on GitHub etc using Composer. Follow the steps below:

1. Create a new access token on GitHub by going to the token settings: .
2. Generate a new token with the necessary repository access permissions.
3. Create an `auth.json` file in the root directory of your project.
4. Add the following content to the `auth.json` file, replacing `` with your actual token:

```
{
    "github-oauth": {
        "github.com": ""
    }
}
```

5. In your `composer.json` file, include the private repositories and required packages as shown in the example provided:

```
{
  "name": "your-project-name",
  "description": "Your project description",
  "require": {
    "wpackagist-plugin/woocommerce": "^5.5",
    "wpackagist-theme/twentytwenty": "^1.9",
    "/": "^1.0",
    "/": "^2.0"
  },
  "repositories": [
    {
      "type": "composer",
      "url": "https://wpackagist.org"
    },
    {
      "type": "vcs",
      "url": "https://github.com//"
    },
    {
      "type": "vcs",
      "url": "https://github.com//"
    }
  ]
}
```

For a fully detailed guide on how to set up private repositories with your project, refer to the [GitHub guide](https://github.com/devuri/Install-Theme-via-Composer-from-Private-Repository-on-GitHub).

### Premium Plugins

[](#premium-plugins)

Many Premium plugins provide a way to install via composer, Composer simplifies the process of managing dependencies by automating the installation, updating, and removal of plugins. This ensures that you are using the correct version of the plugin, reducing compatibility issues and potential conflicts with other WordPress components.

For more information on premium plugins, check out the documentation [Installation of Premium Plugins](https://devuri.github.io/wp-env-config/premium-plugins/).

Local Development Environments (LocalWP)
----------------------------------------

[](#local-development-environments-localwp)

The framework seamlessly integrates with Local WP, enabling you to construct and engage with local environments. Local WP simplifies the process of setting up, managing, and interacting with local WordPress environments, catering to users of Mac, Windows, and Linux.

To configure your environment appropriately, make sure to rename the `.env` file to `.env.local` and adjust the database credentials to match your Local WP settings. Additionally, update the `WP_HOME` to reflect your home URL, for instance: `WP_HOME='http://localhost:10028'`.

The files generated after running `composer create-project devuri/wp-env-app` should be located within the 'app' directory of your Local WP installation.

Here are the database settings for your reference:

```
DB_NAME=local
DB_USER=root
DB_PASSWORD=root
DB_HOST=localhost
DB_PREFIX=wp_
```

> If you encounter the well-known error message "Error establishing a database connection", a simple restart of the site in LocalWP might resolve the issue. Additionally, if you're using a VPN, try disconnecting from the VPN, then start the LocalWP site, and attempt the connection again. After this, you can reconnect to your VPN, and everything should function as it previously did.

Enabling Multi-Tenant Support
-----------------------------

[](#enabling-multi-tenant-support)

Before proceeding with any modifications, it's crucial to ensure the safety of your WordPress site. Make sure to create a comprehensive backup of both your WordPress files and database. For more insights on multi-tenant configurations, consider exploring detailed information available at [multi-tenant documentation](https://devuri.github.io/wp-env-config/multi-tenant/).

### Steps to Enable Multi-Tenant:

[](#steps-to-enable-multi-tenant)

1. Navigate to the public directory of the framework installation and locate the `wp-config.php` file.
2. Open the `wp-config.php` file and find the section where `ALLOW_MULTITENANT` constant is defined. You will need to insert or update the specific line to enable multi-tenant functionality.
3. Modify the file by adding or updating the following line of code, which sets the `ALLOW_MULTITENANT` constant to `true`. This change will activate the multi-tenant features:

    ```
    define('ALLOW_MULTITENANT', true);
    ```

For a reference implementation or to see an example of this configuration in action, you can view the [Project Framework config file example](https://github.com/devuri/wp-env-app/blob/main/public/wp-config.php#L11).

By following these steps, your application installation will be configured to support multi-tenant capabilities, allowing for enhanced flexibility and scalability.

Git Ignore
----------

[](#git-ignore)

For more information on the framework gitignore, check out the documentation [Git Ignore for the Project Framework](https://devuri.github.io/wp-env-app/gitignore/).

Congratulations! You now have wp-env-app up and running. Enjoy developing your WordPress web applications with a lightweight and modular framework. Should you have any questions or encounter any issues submit them through the [issue tracker](https://github.com/devuri/wp-env-app/issues).

Contributing
------------

[](#contributing)

Contributions are welcome! If you find any issues or have suggestions for improvements. Feel free to fork the repository and submit pull requests to contribute to the project.

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity12

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity47

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 95.5% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~9 days

Recently: every ~28 days

Total

37

Last Release

827d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/8fd19f958b007ec6588d0a5ca2fe78e107edd652f286b836d36b5d1781d573a5?d=identicon)[devuri](/maintainers/devuri)

---

Top Contributors

[![devuri](https://avatars.githubusercontent.com/u/4777400?v=4)](https://github.com/devuri "devuri (231 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (11 commits)")

### Embed Badge

![Health badge](/badges/devuri-wp-env-app/health.svg)

```
[![Health](https://phpackages.com/badges/devuri-wp-env-app/health.svg)](https://phpackages.com/packages/devuri-wp-env-app)
```

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
