Datasheet
2
x
CHAPTER 1 INTRODUCING SYMFONY, CAKEPHP, AND ZEND FRAMEWORK
WHAT ARE WEB APPLICATION FRAMEWORKS AND HOW ARE
THEY USED?
A web application framework is a bunch of source code organized into a certain architecture that
can be used for rapid development of web applications. You can think of frameworks as half-
produced applications that you can extend and form to make them take shape according to your
needs. Well, that means half your work has already been done, but for some it is as much a blessing
as a curse because this work was done in a particular way, without your supervision.
Thus all frameworks are either stained with a coding methodology and naming and structural
conventions, or if they try to avoid these restrictions, they need to be heavily confi gured by you.
This either reduces their fl exibility or makes their learning curve signifi cantly steeper. And if you
really want to escape from these problems toward a more library-like approach, you have to sacri-
fi ce some development speed. You can see that frameworks are all about tradeoffs.
That’s why it is really good to take a look at many frameworks and compare their differences.
Perhaps one of them offers conventions that you would use as good practices, anyway? Perhaps
you have nothing against some initial confi guration that allows you to be rapid and fl exible at the
same time? And maybe you want just a library of powerful components to link together by your-
self? The choice is yours, and if you fi nd a way to mitigate their disadvantages, you can fully enjoy
the greatest benefi t of all frameworks: truly rapid development.
Further advantages of frameworks are elegance of code and minimizing the risk of programming
errors. Frameworks conform to the Don’t Repeat Yourself (DRY) principle, which means that they
have all the pieces of logic coded only once in one place. This rule forbids duplication of code,
especially copypasting. This facilitates maintenance of code and prevents nasty errors. Generally,
frameworks promote code reusability and other good programming practices wherever they can,
which is great for programmers who do not have enough knowledge or discipline to care for
quality of code by themselves.
Another great feature is the clean organized look of links that can be done with URL rewriting,
which is supported by most frameworks. Instead of
/animals.php?species=cats&breed=maineco
on
, type just /animals/cats/mainecoon. This is not only appealing to the eye but also very search
engine optimization (SEO)–friendly.
Framework versus Library
The main difference between a library and a framework is that:
‰
libraries are called from your code
‰
frameworks call your code
In other words, a framework in your application is a skeleton that you fi ll with features or serves as
a platform on which you build your modules. Whereas a library instead provides attachable modules
on top of a platform made by yourself. Some people perceive a framework as something better or
more complete than a library, so “framework” became a buzzword that is often overused. That’s
why people call some libraries frameworks, even though they do not invoke developers’ code. There
c01.indd 2c01.indd 2 1/24/2011 5:45:14 PM1/24/2011 5:45:14 PM