zippovich2/wordpress

Developing Wordpress app in modern way using composer.

v1.3.0 2020-10-27 14:54 UTC

This package is auto-updated.

Last update: 2024-10-27 23:12:25 UTC


README

Developing Wordpress app in modern way using composer.

Build Status Packagist

Features

  • Better folder structure.
  • Dependency management with Composer.
  • Easy WordPress configuration with environment specific files.
  • Environment variables with Symfony Dotenv.
  • Filters and actions configuration in .yaml files.

Requirements

  • Docker

or

  • PHP >= 7.3
  • Composer - Install
  • MySql
  • Nginx or Apache2

Installation

  1. Create a new project:

    $ composer create-project zippovich2/wordpress project-name
    
  2. Update variables in the .env files and constants in the.const files (you can use .env, .env.local, .env.dev, .env.dev.local and .const, .const.local, .const.dev, .const.dev.local files depends on your APP_ENV):

    • APP_ENV - set to environment (dev, prod or test).
    • DB_TABLE_PREFIX - use this environment variable to change database table prefix, default is wp_.
    • Database constants:
      • DB_NAME - database name.
      • DB_USER - database user.
      • DB_PASSWORD - database password.
      • DB_HOST - database host.
    • WP_HOME - full URL to WordPress home (https://example.com).
    • WP_SITEURL - full URL to WordPress including subdirectory (https://example.com/wp).
    • Wordpress salts will be generated after the project is created (if you used composer create-project), but you can regenerate them:
  3. Add a theme(s) in public/app/themes/ as you would for a normal WordPress site

  4. Set the document root on your webserver to public folder: /path/to/site/public/

  5. Access WordPress admin at https://example.com/wp/wp-admin/

  6. For enabling WordPress Config - add to begin of functions.php:

    use WordpressWrapper\Config\Config;
    
    $config = new Config($_ENV['PROJECT_ROOT'] . '/config');
    $config->load();

If you are using Docker - you can skip 3, 4 and 5, just run make up or docker-compose up then you can access you site by uri http://localhost:8080.

Folder structure

your-project/
├─ .docker/
├─ config/
|  └─ ...
├─ public/
|  ├─ app/
|  ├─ wp/
|  ├─ index.php
|  └─ wp-config.php
├─ src/
|  └─ ...
├─ var/
├─ tests/
└─ vendor/
  • .docker/ - contain files which are used to build docker environment, you can delete this folder if run app without Docker.
  • config/ - contain .yaml config files, at this moment WordPress Wrapper Config support:
    • filters.yaml
    • actions.yaml
  • public/ - this is root folder, contain:
    • app/ - same as default wp-content WordPress folder.
    • wp/ - contain WordPress core, you should not edit files from this directory.
    • index.php - WordPress core loads here.
    • wp-config.php - here .env* and .const* files are load.
  • tests/ - app tests.
  • var/ - contain docker data(if you use Docker) and logs.
  • vendor/ - composer dependencies.