开发者

CakePHP Application Deployment

I am interested in finding out how folks are deploying their CakePHP applications. I have recently been approached about doing some freelance CakePHP development, which would be a nice opportunity for me to get some experience in the presentation tier (in my FT job I do Java EE development in the business and persistence tiers).

My thoughts are a bit disorganized at this point, but I'm considering the following scenarios:

  • Developer working in an IDE modifies a file, which is automatically (in the background) synchronized with a development web server running locally. This scenario is how I would ideally like to do development... make a change and be able to see the change in action without any extra steps.

  • Developer working in an IDE modifies a file, which is automatically (in the background) synchronized via FTP with a development web server running remotely. This scenario would be useful when I'm traveling using my netbook (which runs my IDE slowly enough as it is without a web server in the mix).

  • Administrator deploys the latest version of a CakePHP application from a source code repository to a web server running locally.
  • Administrator deploys the latest version of a CakePHP application from a source code repository to a web server via FTP.
  • Administrator deploys an older version of a CakePHP application from a source code repository to a web server running locally.
  • Administrator deploys an older version of a CakePHP application from a source code repository to a web server via FTP.

The development tools that I'm most comfortable with are Eclipse, Ant, and Subversion. My preference is to continue using those, but I would consider switching if doing so makes it easy to achieve the scenarios.

Questions:

  • Are these reasonable scenarios, or should do I need to think about development and deployment in a different way?
  • What tools exist that can help simplify development/deployment? Would it be better for me to roll my own solution with Ant, scripts, etc?
  • How do we handle database issues during deployment? How are database connection properties specified for a particular deployment? What if updating to a newer version (or reverting back to an older version) of the CakePHP application requires a change to the database schema and data migration?
  • How do we configure properties that vary between depl开发者_开发技巧oyments? For example consider increased debug and logging levels used during development, preventing payments from being sent to payment gateways during development, etc.
  • How does upgrading or reverting a deployment affect customers? For example what if they are in the middle of a transaction (e.g. purchasing a product)?
  • How do we handle different CakePHP installation types? Files may need to be installed in different locations depending on the installation type. How can we know where files should be installed? The CakePHP book describes development, production, and advanced installations.

Sorry for so many questions in one post, but I think the questions are all related and thought it would be useful to keep the discussion in one place.


Are these reasonable scenarios, or should do I need to think about development and deployment in a different way?

Seems reasonable, although the FTP synchronisation makes me think of Dreamweaver. :)

Consider using an IDE that allows you to connect to a server over (S)FTP, or use one of the following...

What tools exist that can help simplify development/deployment? Would it be better for me to roll my own solution with Ant, scripts, etc?

Jenkins, Capistrano, Phing, Ant, git push/pull, rsync, etc.

How do we handle database issues during deployment? How are database connection properties specified for a particular deployment? What if updating to a newer version (or reverting back to an older version) of the CakePHP application requires a change to the database schema and data migration?

Use cake schema generate and cake schema run update.

How do we configure properties that vary between deployments? For example consider increased debug and logging levels used during development, preventing payments from being sent to payment gateways during development, etc.

Name files that differ accordingly (ie. core.php.prd vs core.php.dev) and rename on install.

How does upgrading or reverting a deployment affect customers? For example what if they are in the middle of a transaction (e.g. purchasing a product)?

So your application files don't end up in an inconsistent state, you should begin by checking out a fresh copy of the application to a new folder. Copy across any user submitted files, rename *.prd files, and then switch the old copy with the new copy (by renaming or using symlinks). Sessions should be stored somewhere that will survive the upgrade (ie. php or database, rather than cake).

How do we handle different CakePHP installation types? Files may need to be installed in different locations depending on the installation type. How can we know where files should be installed? The CakePHP book describes development, production, and advanced installations.

The development install is just as secure as any PHP application that uses .htaccess files to redirect requests (people won't see your code unless you uninstall/misconfigure mod_rewrite and PHP). The production install is slightly more complicated unless you can edit the document roots of your virtual hosts. The advanced install allows you to install Cake anywhere in the filesystem, but adds more complexity (since your files sit in two seperate locations, but may sit in a single repo)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜