Run local wordpress instance from cloned openshift app git repository

I’m developing plugins for a wordpress application hosted with OpenShift. I can clone the git repository from openshift, and I get a structure like this

├── .openshift
│   ├── action_hooks
│   │   ├── build
│   │   ├── deploy
│   │   ├── post_deploy
│   │   └── pre_build
│   ├── config
│   │   └── wp-config.php
│   ├── cron
│   │   ├── README.cron
│   │   ├── daily
│   │   ├── hourly
│   │   ├── minutely
│   │   ├── monthly
│   │   └── weekly
│   ├── languages
│   │   ├── .gitkeep
│   │   └── plugins
│   ├── markers
│   │   └── README
│   ├── openshift.inc
│   ├── pear.txt
│   ├── plugins
│   │   ├── .gitkeep
│   │   ├── myplugin.php
│   │   └── buddypress
│   └── themes
│       └── .gitkeep
├── README
├── README.md
├── libs
│   └── .gitkeep
├── misc
│   └── .gitkeep
└── php
    └── .gitkeep

When deploying to openshift with git push, it automatically moves things to the correct location on the server.

Read More

I want to run a development instance locally and replicate that process. How can I move the plugins, themes, etc to the correct places in wp-content locally in the same way that openshift does on the server?

Related posts

Leave a Reply

2 comments

  1. If you only change WP_CONTENT_DIR without changin WP_CONTENT_URL as well, chances are you will see a broken themes both in the front-end and back-end. The reason is that WordPress will still fetch the resources from your_domain/wp-contents/themes/your_theme/ even though now you just already point wp-content to a different folder.

    Inspired by @bcole, I’ve tried an approach with less burden: which is to put your openshift repo folder under local wordpress folder.

    Here’s the steps:

    1. Download and unfold the updated WordPress package from wordpress.org
    2. Go inside your wordpress folder: $ cd wordpress_folder
    3. Cloen your openshift repo from remote:

      $ git clone ssh://12345678asdf123@your_app-your_domain.rhcloud.com/~/git/your_app.git/
      (you may get the remote url from your openshift dashboard after login)

    4. Initiate your WordPress application locally (you may setup a localhost server and got through classic WordPress 5 minutes start up process)

    5. Modify your wp-config.php file in your WordPress folder (not the one in .openshift/config folder!)

    6. Add these two lines BEFORE define('ABSPATH', dirname(__FILE__) . '/'); :

      define('WP_CONTENT_DIR', dirname(__FILE__) . '/your_app/.openshift');
      define('WP_CONTENT_URL', '/your_app/.openshift');

    7. Copy the themes plugins you want to upload to openshift in your_app/.openshift/
    8. git add, git commit, and then git push to remote
    9. All done!

    The only difference to @bcole‘s approach is that we now put the openshift INSIDE the wordpress folder, not NEXT TO it. The benefit is that now we can define WP_CONTENT_URL in a more decent manner.

    Hope this would help!

  2. One possibility for local development could be to create an instance of WordPress that is configured to look in all the right folders of the project repository without actually moving any of the project structure around. You can achieve this with a combination of symlinks, and wp-config options.

    Possible setup for your project:

    1. Create a local WordPress install

    Put it anywhere, perhaps next to the main project repo.

    ├── project-repo-checkout
    │   └── .openshift, etc
    └── wordpress
    

    2. Create a special local wp-config.php

    Put it in the wordpress directory, or one level up.

    You can create a clean wp-config file just for development, or you could do this if you need to use the wp-config in the project repo:

    define('WP_CONTENT_DIR', '/path/to/repo/.openshift');
    require('/path/to/repo/.openshift/config/wp-config.php');
    

    The option WP_CONTENT_DIR tells WordPress to go look in the folder .openshift and treat it as if it were the wp-content folder. So then it will look for ‘themes’ and ‘plugins’ in the .openshift folder instead.

    Here is my setup, as another example

    I have a git repo for WordPress that looks a bit like this:

    ├── wp-config.php
    ├── src
    │   ├── plugins
    │   ├── themes
    │   └── other stuff
    └── wordpress
        ├──wp-admin
        └──wp-includes
    

    Note the wordpress core files are off in their own folder, and all the development stuff is in src and wp-config.php lives outside of everything and is git-ignored.

    This line in wp-config.php tells WordPress to go look in the development folder for everything:

    define('WP_CONTENT_DIR', '/path/to/project/src');
    

    And then it will look in ‘src’ for folders called ‘plugins’ and ‘themes’ and it’s as if ‘src’ is now the wp-content directory.

    Some caveats I learned along the way: It’s not possible to symlink the ‘themes’ or ‘plugins’ folder because WordPress uses PHP code that checks for the presence of actual directories. It IS possible to symlink the ‘uploads’ folder though.