PHP and Smarty on Large-Scale Web Development > Why PHP and Smarty on Large-Scale Web Development?
To achieve efficiency on your large-scale web projects, start by observing a set of principles. These principles are not meant to stop you from doing what you do best; the goal is for them to help you manage the way software is developed.
The following list describes the principles of large-scale web development:
A system composed of several components that can be interchangeable and fit together.[*] On a modular architecture it's easier to divide the whole project into specific tasks.
[*] Many frameworks were created to do exactly that. See, for example, the PHP Extension and Application Repository PEAR (http://pear.php.net/) or the Zend Framework (http://framework.zend.com/), both written entirely in PHP.
Teams where every member has a specific task assigned. Some teams can also be divided into specialized groups like developers, web designers, and software testers.
Version control solutions to maintain builds
Version control helps you manage what team members are doing and when you should release a new version (or a build) of your software solution.
 There are many popular version control solutions, both closed and open source. CVS (http://www.nongnu.org/cvs/), is one of the oldest and most used solutions. Subversion (http://subversion.tigris.org/) is rapidly gaining popularity among open source developers. Visual SourceSafe (http://msdn.microsoft.com/ssafe/) is a solution from Microsoft.
Not building from scratch
Always try to reutilize previously developed components into new solutions. This saves precious time on every new project.
By following these simple rules, you gain control over your projects and everyone on your team therefore becomes much more productive.
Whether you're an engineering manager or a developer, the following sections have great value for you. Next, we show you how PHP and Smarty fit into the large enterprise development schedule.
Instead of asking this question, we ask you "Why not"? Why shouldn't you use this language as your choice for enterprise tasks? How do you make this decision?
According to different authors, there are several criteria that you can use to make that choice:
 For a good opinion on how to choose the right programming language, see Spinellis, D., "Choosing a programming language," Software, IEEE, Volume 23, Issue 4, Jul.-Aug. 2006, pp. 62 63.
The language syntax must be easy to learn and to understand. There should be a programming style that developers agree upon. The same logic should be expressed in only one way.
The same program must be able to run on different platforms. There should be a sufficient enough layer of abstraction between the programming language and the host operating system.
The language must provide ways of checking its own syntax and variable types either on compilation or at runtime. It should be easy to debug and test written programs.
There should be available literature (books, magazines, web sites, source-code repositories) about the programming language. It must be easy to get help, hire a consultant, or discuss technical details on the Internet.
Written programs should be easy to maintain or adapt.
To fully understand why PHP is a good choice for large-scale web development, let's see how it fits into the previous list of criteria. PHP syntax is very easy to learn and to understand, as opposed to other scripting languages.
Code written in PHP can run on almost every flavor of UNIX, AS/400, MAC OS X, Microsoft Windows, Novell Netware, OS/2, RISC OS, SGI IRIX and Solaris.
It can run as a CGI[ ], and also as a module for popular web servers. PHP is open source software, so even if there isn't a version available for your server or platform, you can still compile it.
[ ] CGI Common Gateway Interface is a protocol for exchanging information between an application and a web server. Although Apache modules made CGI obsolete, it is now gaining ground through the use of FastCGI and as a way to run PHP with the lighthttpd web server.
PHP has a number of mechanisms to check code syntax, beginning with its built-in lint[||] checker. Also, there are numerous debugging and profiling tools, either commercial or free of charge.
[||] Although the PHP interpreter performs a syntax check on every code run, you can do it explicitly on the command line through the -l option of the PHP CLI (Command-Line Interface) or through the less-known runkit (http://pt.php.net/manual/en/function.runkit-lint.php) PECL extension.
PHP is considered the most popular web development language, used on more than 19 million web sites around the globe.[#] It has a community-maintained web site (http://www.php.net), where you can find documentation for every PHP function available.
[#] See PHP Usage Stats for December 2006 (http://www.php.net/usage.php).
There are numerous code library projects, with PHP Extension and Application Repository (PEAR)[**] being the most popular and most commonly used right now. Another recent framework project is the Zend Framework, a complete MVC code library developed by Zend and the open source community.
[**] PEAR PHP Extension and Application Repository. PEAR is the first and most popular PHP code library repository (http://pear.php.net/).
 MVC Model View Controller pattern. For a complete description of the pattern, see Fowler, M., "Patterns of Enterprise Application Architecture," Addison-Wesley Professional, November 2002. (http://www.martinfowler.com/eaaCatalog/modelViewController.html).
You should also take a look at eZ Components, a development framework from eZ Systems. eZ Components is a general-purpose, enterprise-ready PHP components library.
 More information is available at the eZ Components product page (http://ez.no/ezcomponents).
In short, PHP is a robust, 10-year-old scripting language driven by a large open source community with different companies offering training, certification, support, and consulting services.
Now that you know why you should choose PHP, you might be asking why you would use Smarty. Why should you use a templating engine in the first place?
The most important reason is the ability to separate logic from presentation. By using a template solution, you effectively have distinct ways to write logic code and presentation or layout. You can then distribute tasks throughout your team more easily.
PHP itself can be used as a template language, but you can gain control over the behavior of the pages if you use a specific interpreted template language. By providing only a "safe" set of functionalities, web designers won't be able to incur any security mistakes or make your web site behave in unexpected ways.
Smarty is an extensible template language interpreted by PHP on runtime. It is available as open source and has a large community behind it. There is plenty of documentation available on the Web and in print.
There are, of course, many other template engines available for PHP. What, then, is the biggest advantage of Smarty? Most of the other engines don't have as many features as Smarty does.
The only comparable template engine is Savant,[ ] mainly because of its speed and features. Its only disadvantage is its lack of a template language.
[ ] Savant is a powerful but lightweight object-oriented template system for PHP. Unlike other template systems, Savant by default does not compile your templates into PHP; instead, it uses PHP itself as its template language so you don't need to learn a new markup system (http://phpsavant.com/).
Savant templates are written in pure PHP, making it impossible to protect the template code from the full power of PHP. This can be a problem if you need to have control over what your templates can run.[||||]
[||||] For a more detailed comparison, see Maia, et al., "Smarty PHP Template Programming and Applications," Packt Publishing, April 2006.
To conclude, PHP and Smarty are excellent choices for large-scale web development projects involving large teams and tight deadlines. You should feel comfortable using them together.[##]
[##] Some authors argue exactly the opposite, but we think the problem is in their approach to web development, not in the choice of PHP. See, for example, Crane, A., "Experiences of Using PHP in Large Websites" (http://www.ukuug.org/events/linux2002/papers/html/php/).