studio icon indicating copy to clipboard operation
studio copied to clipboard

Support WordPress in a subdirectory

Open davisshaver opened this issue 1 year ago • 4 comments

I am trying to add an existing site in a folder like ~/my-site.

my-site uses WordPress in a subdirectory. This is the basic structure of my-site:

.
├── index.php
├── salt.php
├── wp
├── wp-cli.yml
├── wp-config.php
├── wp-content
└── xmlrpc.php

Studio does not recognize my-site as an existing WordPress folder.

Context: I use WordPress in a subdirectory so that I can use the WordPress composer package to manage which version of Core is installed.

It looks like the immediate cause for the error message is the logic in this function: https://github.com/Automattic/studio/blob/trunk/src/lib/fs-utils.ts#L47-L53

However I don't know if updating that function would be enough to fix the issue, there definitely could be other parts of Studio which could not be compatible with the subdirectory approach for sites.

davisshaver avatar Apr 17 '24 13:04 davisshaver

Hi @davisshaver ! Thanks for testing Studio and sharing your report. Currently, Studio expects the whole WordPress installation in the chosen WordPress folder.

Would you mind sharing more detailed steps showing how you would set up the site using WordPress Composer so we can review whether it's feasible to add support for such a case in the future?

wojtekn avatar Apr 18 '24 11:04 wojtekn

Hi @wojtekn, thanks for the reply!

The setup is basically what is described in WP.org codex for giving WordPress its own directory.

Here is a starter project which you can reference: https://github.com/johnpbloch/wordpress-project/

Here's a more complex starter project using similar techniques: https://github.com/szepeviktor/composer-managed-wordpress

I'd be glad to help test any work on this and potentially contribute in other ways. This would be a great feature to add! I know that many developers, especially those working on enterprise sites, use this approach for managing their sites. Thank you for looking into it.

davisshaver avatar Apr 18 '24 12:04 davisshaver

I attempted to get Bedrock up and running with Studio and ended up hitting this error:

Failed to start the site server

Please verify your site's local path directory contains the standard WordPress installation files and try again. If this problem persists, please contact support.

Bedrock installs WordPress via Composer in a subdirectory:

├── composer.json
├── config
│   ├── application.php     # Primary wp-config
│   └── environments
│       ├── development.php
│       ├── staging.php
│       └── production.php
├── vendor                  # Composer dependencies
└── web                     # Public document root
    ├── app                 # WordPress content dir
    │   ├── mu-plugins
    │   ├── plugins
    │   ├── themes
    │   └── uploads
    ├── wp-config.php
    ├── index.php
    └── wp                  # WordPress core

It's possible to get Bedrock working on other WP local dev platforms, such as Local and DevKinsta, and it'd be great if Studio would allow supporting a non-traditional WordPress installation

retlehs avatar Apr 24 '24 21:04 retlehs

We should contribute this enhancement to wp-now too, so both tools support this configuration.

danielbachhuber avatar Apr 24 '24 22:04 danielbachhuber