Deploying WordPress with Composer

You can do whatever suits your needs, such as still using composer but configuring your implementation to place the directories back into the root along with core, however the primary purpose in having core stand-alone from other directories is for separation of concerns that are not dependant upon one another sharing the same path.

The wp-content directory can already be moved outside of the installation root, natively, using constants without composer.

For example:

define( 'WP_CONTENT_DIR', dirname(__FILE__) . '/blog/wp-content' );
define( 'WP_CONTENT_DIR', dirname(__FILE__) . '/blog/wp-content' );

define( 'WP_CONTENT_URL', 'http://example/blog/wp-content' );

define( 'WP_PLUGIN_DIR', dirname(__FILE__) . '/blog/wp-content/plugins' );
define( 'WP_PLUGIN_URL', 'http://example/blog/wp-content/plugins' );
define( 'PLUGINDIR', dirname(__FILE__) . '/blog/wp-content/plugins' );

define( 'UPLOADS', 'blog/wp-content/uploads' );

So even core acknowledges that the relationship between core and wp-content is not dependant upon wp-content being a child of the root installation.

If WordPress did not have 20 years of legacy behind it, I doubt very much that the folder structure we see today would remain.

The composer way of doing it has the opinion that they should be separate because as we’ve progressed and the web, tooling and applications we build become more complex we realise that there’s somethings we don’t want exposed to the root, often for security reasons but also for logical reasons (i.e. application-domains).

I’ve personally used:

This is from one of WPSE’s very own Giuseppe Mazzapica / @gmazzap housed under the wecodemore imprint founded by another of WPSE’s very on Franz Josef Kaiser / @unserkaiser and which has received contributions from other WPSE members and the greater WP at large.

We all tend to agree that this separation of concerns is a good way to go about structuring our applications, but again, you’re not bound to it.

Using wpstarter for example, you can achieve what you want by altering the composer file to specify your desired paths.

From:

"extra": {
    "wordpress-install-dir": "public/wp",
    "wordpress-content-dir": "public/content",
    "..." : "...",
    "installer-paths": {
        "public/content/plugins/{$name}": [
            "type:wordpress-plugin"
        ],
        "public/content/mu-plugins/{$name}": [
            "type:wordpress-muplugin"
        ],
        "public/content/themes/{$name}": [
            "type:wordpress-theme"
        ]
    }
}

To:

"extra": {
    "wordpress-install-dir": "public/wp",
    "wordpress-content-dir": "public/content",
    "..." : "...",
    "installer-paths": {
        "public/wp/content/plugins/{$name}": [
            "type:wordpress-plugin"
        ],
        "public/wp/content/mu-plugins/{$name}": [
            "type:wordpress-muplugin"
        ],
        "public/wp/content/themes/{$name}": [
            "type:wordpress-theme"
        ]
    }
}

composer excerpt shortened for brevity

…and that should do what you need.

See: