Thursday, November 27, 2008

Web applications in my world "LAMP stack"

In this here my 2nd post, I'll be sharing my views on Web Applications under my environment- the LAMP (Linux,Apache,MySQL,Php)

PHP has its humble roots going back to 1995,when it was invented as a 'Personal Homepage Parser' - that moniker has been since dropped and PHP doesn't stand for anything in particular anymore. Originally,it followed the CGI script paradigm where each page request would launch a seperate heavy-weight process.whilst this is still possible,nowadays it more common for php to be running inside the server as a plugin (ISAPI plugin under IIS,mod_php under Apache).this means said requests may be handled by light weight threads,without the expensive startup stage for each launch.

Whilst PHP is a scripted language,byte-code can be generated using a vendor-specific engine,such as the Zend Optimizer.

php has similar concepts to other web application frameworks - application state is stored in either session or request 'objects' (i use the term loosely,they are technically arrays)

PHP is rather flexible,it does not impose a 'php-way' of doing things.as a result,there are a number of frameworks based on PHP,some of which are rather specialised,but still extensible (Wordpress for blogs,Joomla and Xoops for content management).

There are other,real frameworks that run on PHP including some that support scaffolding (automatic code generation).For some reason,most of them (if not all) use the MVC (Model-Viewer-Controller) design pattern.

As a scripted language,there is no special 'build' or 'deploy' stages for PHP.that means deployment might be unzipping files onto your production server - which is a terrible way of doing it, by the way.

I tend to use a Subversion repository to manage my project assets and change management,once I'm happy with the testing (or more often,the deadline has approached),i deploy from the repository to production server.Apache's mod_rewrite and .htaccess files ensure only legitimate php files are served,and nothing else that could be a security risk.

mod_rewrite is quite useful for another reason - as It's name suggests,it rewrites http requests on the fly.the most common use is to url prettification.a url like http://eg.com/user/jane/photo can be mapped to http://eg.com/main.php?mod=user&id=jane&section=photo .

PHP is not without weaknesses- at times CPU-intensive processes time out,the default setting in the php.ini file sets that to 30 seconds,which is not adequate for the generation of complex reports.i use the 'Linux' part of the stack to bypass this,I schedule a script to be launched in its own shell using cron then cache the result (eg a PDF report). A PHP script launched in this way can execute at it's leisure, as it has no execution time restrictions.

That's about it for Web apps under LAMP.

1 comment:

  1. Sounds interesting but with so many tools how do you manage your projects?

    ReplyDelete