What Is Your Preferred PHP Deployment Strategy

What is your preferred php deployment strategy?

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.

Is there any stable tool for complete web deployment & CI?

There is a lot of chaos in your question:

  1. Configuration management:

    setup web services, databases, etc with tools like Ansible, Saltstack, Puppet, Chef
  2. Deploy code from repository to production:

    build package like Docker image or deb\rpm package or deploy directly from sources with Ansible\Fabric\Capistrano scripting
  3. Continuous integration:

    Automatic get sources after each commit or by scheduling, deploy it to the test environment, execute a tests and then merge changes into master or even deploy it to the production with tools like Jenkins, Hudson, Teamcity, Buildbot, etc
  4. Service orchestration for big complex environment:

    When you have a lot of components and cloud instances, environment required complex design and management. For this cases DevOps uses "cloud operating systems" like Mesosphere or orchestration tools like Nomad or Juju

In simplest case I recommend use Ansible for setup your components, Vagrant for local testing and AWS or any VPS for production. When your team will grow for automation you can use Jenkins for private repositories or Travis-ci for open source projects.

And hire a good DevOps when you'll grow ;)

Deploying CodeIgniter (or any PHP projects) to the live site?

I use Phing for all my building needs.

I've created several tasks like, prod, staging, debug. When i want to push all data to my production server, i just use phing prod. This will checkout all code from my repo, do some config changes, run all static files like css and javascript through a minifier etc.

More info on Phing here:

Phing.info

http://www.slideshare.net/hozn/phing-building-with-php

Professional development-deployment strategy for a lone freelancer working on a website?

If you're not familiar with revision control systems, I suggest you start with Subversion to learn the basic concepts and get used to the workflow. Git is very powerful but can be a bit daunting at first if you've never worked with a SCM tool before.

The easiest way to get a SVN repository running is using Apache to access the repository via http or https. You can find tutorials all over the web about setting up Apache + SVN (examples here and here).

Once your repository is working, any decent IDE will easily let you link your project to SVN and you can start checking out, committing, branching, etc.

Regarding deployment using SVN, a common strategy for projects that don't need compiled binaries (eg. PHP) is to tag a specific revision with a specific tag, for example RELEASE_2011_06_03, and then check out that specific tag in the production web server. When you're ready for a new release, you tag again and update the production server to the new release tag. By keeping the 'live' code linked to SVN you can easily deploy new versions or rollback to older versions automagically.

Using Apache ANT to deploy web applications?

Last time I checked (long ago) there was no remote sync task in Ant (only local). You would have to write a shell script that calls rsync and execute this from Ant instead. There is a number of remote tasks though. And you could check out your code from your VCS instead of syncing it to the server.

On a sidenote, you might want to consider Phing over Ant. It's a port of Ant to PHP. It has a FileSync Task. You can also add your own Tasks (written in PHP) and is commonly used in Continuous Integration servers for PHP.

Also see What is your preferred Deployment Strategy for PHP and a couple others.

PHP Automated Deployment and Testing

Since you're working with Java, you might consider using Hudson (also mentioned in your other question), which has the ability to execute build tasks consisting of several 'steps' One step step could be unit testing your Java App, another unit testing a PHP app, yet another deployinhg Java app, and another deploying a PHP app (and you could add some more ;P )

It has a Maven plugin, so you could actually use your existing Maven scripts.



Related Topics



Leave a reply



Submit