ClassicPress Documentation

Installing with Composer

You can use composer to install recent release versions of ClassicPress as well as nightly builds.

This is a good option if you want to automate more steps of the installation process.

Below you can find instructions for installing the latest release version and the latest nightly build using composer, as well as what to do after that to end up with a working site.

Installation steps (beta)Link to this section

  1. Create a composer.json file in your root directory
  2. Copy the following code into the composer.json file:
    {
        "repositories": [
            {
                "type": "composer",
                "url": "https://wpackagist.org"
            }
        ],
        "require": {
            "classicpress/classicpress": "@beta"
        },
        "extra": {
            "wordpress-install-dir": "classicpress"
        }
    }
    

    NOTE 1: The wpackagist.org repository allows you to install WordPress plugins using composer (documentation about this feature coming soon).  If you don’t need this functionality, then you can remove this section.

    NOTE 2: ClassicPress is currently still in the beta release stage; you’ll be able to remove the @beta version specification after 1.0.0 is released.

  3. In a terminal window, run composer install in your project directory.
  4. Create the MySQL database for the new site.
  5. In the wp-config.php file, edit following constants: DB_NAME, DB_USER, DB_PASSWORD, DB_HOST, and WP_HOME
  6. Go to your site home url, and follow standard ClassicPress install steps

Installation steps (nightly)Link to this section

The steps are mostly the same, but you need to define the ClassicPress-nightly repository in your composer.json file.  Here is a sample composer.json with these changes:

{
    "repositories": [
        {
            "type": "composer",
            "url": "https://wpackagist.org"
        },
        {
            "type": "vcs",
            "url": "https://github.com/ClassyBot/ClassicPress-nightly.git"
        }
    ],
    "require": {
        "classicpress/classicpress": "@beta"
    },
    "extra": {
        "wordpress-install-dir": "classicpress"
    }
}

Note: when running composer install, you will be prompted to create a GitHub API token due to the large number of tags in the ClassicPress-nightly repository.

After installationLink to this section

For more information about turning ClassicPress installed via composer into a working site, see this comment on GitHub.

Or, you can try out Bedrock by Roots, which is a WordPress boilerplate that uses composer under the hood and also works fine with ClassicPress.  Here’s how to create a new site this way and switch it over to ClassicPress:

composer create-project roots/bedrock my-site
cd my-site
composer remove roots/wordpress
composer require classicpress/classicpress:@beta

Then, edit your wp-config.php file (which can be found in the web/ subdirectory of your project) and fill in the required values.  Serve your site from the web/ subdirectory only: do not expose the files in the main project directory via your web server.

Configuration changesLink to this section

A common use of a composer-based installation workflow is to keep core and all plugins and themes up to date in a development environment, and then deploy everything to production at once.

If this is what you have in mind, you’ll probably want to disable ClassicPress’ built-in auto-updates by adding the following line to your wp-config.php file:

define( 'WP_AUTO_UPDATE_CORE', false );

There are various other changes you can make to the automated update functionality according to your preferred setup.  See this post for more details.

Other changes that are also probably a good idea:

  • Using filesystem permissions, do not allow ClassicPress to write to any directories outside wp-content/uploads.  Instead, set up a separate deploy process to make changes to the core software and plugins/themes.  This makes many common attacks and other problems impossible.
  • Make sure the composer.json, composer.lock, and other files in the project root directory are not publicly accessible from the web server.  The easiest way to do this is to make sure your web server is only hosting files from the subdirectory listed as the wordpress-install-dir in your composer.json file.

Migrating from WordPressLink to this section

ClassicPress uses the same file and folder structure as WordPress, so if you already have a working composer-based WordPress installation, you can switch it over to ClassicPress very easily.  Just remove your WordPress package (probably johnpbloch/wordpress or roots/wordpress) and install classicpress/classicpress instead.