Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is your workflow for creating websites based on WordPress?

I a starting a project where 2 people will be developing a site on WordPress. It also may be necessary to have a development server setup where my client can view changes to the site before we push it live. There also may be database changes (like wordpress settings) that should be pushed all the way from development to dev to production.

I am wondering what the best workflow is for this. I understand the general concepts because I usually develop in Rails and therefore run migrations and use capistrano and git, but I would like to have the same tight workflow for a WordPress site. Any experienced WordPress developers out there?

Update: Maybe I did not make this clear enough but I understand wordpress. I have created 5-10 wordpress blogs and customized functionality. However, I have never worked on a wordpress site with multiple people or had to deal with having a dev, staging, and production environment.

Thank you!

like image 953
Tony Avatar asked Oct 27 '22 04:10

Tony


1 Answers

To deal with this type of DEV and PRODUCTION environment, I've written a perl script to help me with what would otherwise be manual work. I've given certain steps familiar names so I remember to run them in the correct order. I only have DEV under SVN. I create a PRODUCTION environment each time with this script. That way I don't have to worry about maintaining 2 branches of code.

I'm using SVN so I choose a new checkout directory (like /tmp/foobar) of my DEV code. It's not going to be there very long.

Optional step 0: diff database structures

mysqldump -d -u USER -pPASS mydotcom > production.sql
mysqldump -d -u USER -pPASS mydotcom_dev > development.sql
vim -d production.sql development.sql

Sometimes plugins will add tables, and this will show that. Otherwise I replay the changes made within tables (install a plugin) when it's not worth it to diff certain tables and copy SQL statements.

step 1 clean: The script deletes all files in the current directory, do a fresh svn checkout of the DEV branch. This fresh checkout is going to be transformed into the PRODUCTION code and copied to its webroot.

step 2 make: perl runs a vim search and replace of the database name in wpconfig.php. The search and replace is just as easily done in perl.

system('vim -c "%s/define(\'DB_NAME\', \'mydotcom_dev\'/define(\'DB_NAME\', \'mydotcom\'/g | w | q" wp-config.php'); 

Remove local file uploads directory (so we don't overwrite the PRODUCTION one). wpcontent/uploads I believe it is on a standard install.

Another find and replace on all text files within the project that have my DEV url, for example

vim -c "%s/dev\.mydot\.com/www.mydot.com/g | w | q FILENAME.php

step 3 install. Backup the wpcontent/uploads with dircopy() to be safe. Do a dircopy() of this cleaned up directory to the PRODUCTION webroot. Remove all .svn directories within the webroot like so:

find /PRODUCTION/WEBROOT -ignore_readdir_race -name .svn -exec rm -fr {} \; >/dev/null 2>&1

Now your DEV code has been transformed into your PRODUCTION code replacing all hardcoded URLs and keeping safe around the uploads directory that is not in SVN. You can even have it stop and start apache for you too. I hope my solution helps solves your problem.

like image 128
ojreadmore Avatar answered Jan 02 '23 21:01

ojreadmore