Viewed   55 times

I'm beginning a new project in PHP and I'd love to get some feedback from other developers on their preferred strategy for PHP deployment. I'd love to automate things a bit so that once changes are committed they can be quickly migrated to a development or production server.

I have experience with deployments using Capistrano with Ruby as well as some basic shell scripting.

Before I dive head first on my own it would be great to hear how others have approached this in their projects.

Further information

Currently developers work on local installations of the site and commit changes to a subversion repository. Initial deployments are made by exporting a tagged release from svn and uploading that to the server.

Additional changes are typically made piecemeal by manually uploading changed files.



For PHP, SVN with Phing build scripts are the way to go. Phing is similar to ANT but is written in PHP, which makes it much easier for PHP developers to modify for their needs.

Our deployment routine is as follows:

  • Everyone develops on the same local server at work, every developer has a checkout on his machine back home as well.
  • Commits trigger a post-commit hook which updates a staging server.
  • Tests are ran on staging server, if they pass - continue.
  • Phing build script is ran:
  • Takes down production server, switching the domain to an "Under construction" page
  • Runs SVN update on production checkout
  • Runs schema deltas script
  • Runs tests
  • If tests fail - run rollback script
  • If tests pass, server routes back to production checkout

There's also phpUnderControl, which is a Continuous Integration server. I didn't find it very useful for web projects to be honest.

Thursday, August 25, 2022

I would store the dates in the MS-SQL format to assist in using the date manipulation functions in T-SQL to their fullest. It's easier to write and read

WHERE DateDiff(d,field1,now()) < 1

Than to try and perform the equivalent operation by manipulating integers

To convert a MsSQL date into a unix timestamp use dateDiff:

SELECT DATEDIFF(s,'1970-01-01 00:00:00',fieldName) as fieldNameTS
FROM TableName
WHERE fieldName between '10/1/2008' and '10/31/2008'

To Convert an Unix Timestamp into a MsSQL Date, you can either do it in PHP:

$msSQLDate = date("Y-m-d H:i:s", $unixDate );

or in MsSQL

INSERT INTO TableName ( 
  DATEADD(s,'1970-01-01 00:00:00', ? ) 

Where parameter one is int($unixDate)

Friday, December 9, 2022

In Phing, if your deployment is Phing based, you could use the ReplaceTokens filter.

Example (not tested):

<target name="-modify-config"
        hidden="true" description="Modifies the xyz.conf ">
  <copy file="${}/xyz.conf.dist"
        overwrite="true" >
      <replacetokens begintoken="%" endtoken="%">
        <token key="KEY_A" value="${value.a}" />
        <token key="KEY_B" value="${value.b}" /> 
Tuesday, November 22, 2022

Google Charts is an excellent choice if you don't want to use Flash. It's pretty easy to use on its own, but for Rails, it's even easier with the gchartrb gem. An example:'320x200', "Things I Like To Eat", false) do |pc| "Broccoli", 30 "Pizza", 20 "PB&J", 40 "Turnips", 10 
  puts pc.to_url 
Friday, October 14, 2022

Capistrano default behavior is to 'touch' all assets files. (To make sure that any cache get the deployment date). Assets are images, stylesheets, etc.

If your PHP application is not using these directories, capistrano complains in such an ugly way.

To disable asset timestamps updates, simply add:

 set :normalize_asset_timestamps, false

to your deploy.rb

Friday, September 16, 2022
Only authorized users can answer the search term. Please sign in first, or register a free account.
Not the answer you're looking for? Browse other questions tagged :