Tag: php frameworks
Summarizing and Extending PHP
by Royston Olivera on Sep.03, 2009, under Technical
In Part 1 of the this series, I introduced PHP and spoke about how it has evolved with every release into a mature language.
Summarizing PHP
Here I would be speaking more about the advantages of PHP.
- The HTML relationship
PHP is always embedded in HTML in code islands. One key advantage to using PHP as opposed to some other solutions is that PHP code is all executed at the server, with the client only receiving the results of the script. What this means is that users never see your PHP source code because they are never sent it: they only see what you want them to see. - Interpreting vs Compiling
PHP uses a blend of interpretation and compilation in order to provide the best mix of performance and flexibility to programmers. Behind the scenes, PHP compiles your script down to a series of instructions (called opcodes) whenever it is accessed, and these instructions are then executed one by one until the script terminates. PHP re-compiles your script each time it is requested. This constant recompilation may seem a waste of processor time, but it is actually not all that bad because you no longer need to worry about hand recompiling your scripts when you make any changes. The speed hit of regular compilation is nullified entirely by the use of PHP accelerators. One major advantage to having interpreted code is that all memory used by the script is managed by PHP, and the language automatically cleans up after every script has finished. This means that you do not need to worry about closing database links, freeing memory assigned to images, and so on, because PHP will do it for you. - PHP is cross-platform, free, fast, capable, extendable, reliable and advancing
This may seem to be a simple point but it covers all the features that a superior programming language must possess. It can be run on Windows, Linux, BSD, Mac OS X, and Solaris, as well as a variety of other platforms.
In the majority of scripts, PHP will easily compete with both Perl and Python, and usually pull ahead of Microsoft’s ASP.NET by about 10-15%. Add to that the fact that PHP code can be cached for execution.
What makes PHP capable is the thousands of pre-written functions that perform a wide variety of helpful tasks like database handling, file uploads, FTP, email, graphical interfaces, generating Flash movies, and more.
PHP is extendable. Writing your own extension to PHP is a common and easy way to implement speed-critical functionality, and PHP’s extension API is a particularly rich and flexible system.
PHP is reliable. As an official Apache Foundation software project, PHP is brought to you by the same people that produce Apache, the world’s most popular web server.
PHP is advancing. With the release of PHP 5, PHP has introduced features that have long been waited for, including more comprehensive error handling, better object orientation, and, of course, more speed. - When to and not to use PHP???
Owing to its fast development time, easy maintenance, and overall fast execution time, it is rare to find PHP is not the best choice for a web application. Homepages (big and small), database front-ends on the web, command line shell scripts where you want extra functionality, and even basic GUI development are all popular uses for PHP, and it excels at them all. If you are doing anything that displays its text through a web browser, you are likely to find that PHP is your best choice. There are two situations when PHP is not recommended. Firstly, if your not developing a web application and you desperately need all the performance you can get, you should be using C and C++. Secondly, if you are adding to a system which already has a lot of code already written in another language, then coding parts in PHP will only make your maintenance job more difficult, so you are likely to find it easiest in the long run to keep using the old language.
Extending PHP and Frameworks
The base of the PHP language is very simple, having just enough to set and retrieve variables, work with loops, and check whether a statement is true or not. The real power behind PHP comes with its extensions – addons to the base language that give it more flexibility.
- Core Extensions
Core extensions are extensions that are bundled with PHP itself, and enabled by default. For all intents and purposes they are part of the base language, because, unless you explicitly disable them (few people do, and sometimes you cannot), they are available inside PHP. - Bundled Extensions
Bundled extensions are extensions that are bundled with PHP, but not enabled by default. These are normally commonly used, which is why they are bundled, but they are not available to you unless you specifically enable them. For example, the mechanism to handle graphics creation and editing is handled by an extension “GD Library” that is bundled with PHP. - PECL - PHP Extension Code Library
PECL stands for “PHP Extension Code Library”, and is as a subset of the PHP Extension and Application Repository, PEAR. PECL (pronounced “pickle”) was originally created as a place where rarely used or dormant bundled extensions could be moved if they were no longer considered relevant. PECL has grown a lot since its founding, and is now the home of many interesting and experimental extensions that are not quite important enough to be bundled directly with PHP. - Third Party Extensions
Third-party extensions are written by programmers like you who wanted to solve a particular problem that was unsolvable without them creating a new extension. - DIY - Do It Yourself
Finally, Do-It-Yourself (DIY) extensions are simply extensions you created yourself. PHP has a remarkably rich extension creation system that makes it quite simple to add your own code as long as you know C.
PHP has also attracted the development of many frameworks that provide building blocks and a design structure to promote rapid application development (RAD). Some of these include CakePHP, PRADO, Symfony and Zend Framework, offering features similar to other web application frameworks.