felixarntz / wordpressdev

WordPress core development environment based on Lando.
GNU General Public License v2.0
13 stars 0 forks source link

Allow running from src in addition to build #8

Open westonruter opened 5 years ago

westonruter commented 5 years ago

Now that we can run from src again this should be an option for this Lando setup.

In large part, I believe it would involve modifying the .lando.yml as follows:

diff --git a/.lando.yml b/.lando.yml
index e313e68..6e169ea 100644
--- a/.lando.yml
+++ b/.lando.yml
@@ -9,6 +9,11 @@ config:
   database: mariadb
   xdebug: false

+proxy:
+  nginx:
+    - src.wordpressdev.lndo.site
+    - build.wordpressdev.lndo.site
+
 services:
   appserver:
     composer:
@@ -21,7 +26,8 @@ services:
       - apt-get install nodejs -y
       - apt-get install zip -y
       # Allow loopback requests to work.
-      - echo "127.0.0.1  wordpressdev.lando.site" >> /etc/hosts
+      - echo "127.0.0.1  build.wordpressdev.lando.site" >> /etc/hosts
+      - echo "127.0.0.1  src.wordpressdev.lando.site" >> /etc/hosts
     install_dependencies_as_me:
       # Setup environment variables and WP-CLI configuration.
       - if [ ! -e $LANDO_MOUNT/.env ]; then cp $LANDO_MOUNT/config/.env $LANDO_MOUNT/.env && sed -i "s#/app#$LANDO_MOUNT#" $LANDO_MOUNT/.env; fi

Additionally, we'd need to modify _wordpressdev_detect_core_path_relative() to look at HTTP_HOST to determine the WP_CORE_PATH_RELATIVE:

https://github.com/felixarntz/wordpressdev/blob/c8d0a83040f97e91216a5117448c6375e291dca8/public/functions.php#L8-L44

felixarntz commented 5 years ago

I never particularly liked the need for build and src in the domain name, as this may have all sorts of weird side effects in multisite. It is technically already possible to run from src, all you'd need to do is adjust the path core should be used from (for example public/core-git/src instead of public/core-git/build).

Running from src vs build was another reason I wanted to implement the flexibility of exchanging the core directory, in addition to git vs svn.

It's a bit annoying that the environment variables don't persist (hopefully fixed soon, but even without it you could at least rely on wp-cli.yml), but I think that part is sufficient to handle the src vs build approach.