Daily Archives: November 3, 2010

Introducing Smarty: A PHP Template Engine


by Joao Prado Maia

Most PHP developers go through scores of changes in regards to their development expertise. They usually start by creating simple scripts to add dynamic features to their Web sites, then go on to add new features. This process leads to more complexity with the mix of PHP and HTML. It is quite common to see PHP scripts that include other files, with the ultimate objective of reusing code and HTML widgets. One that includes file outputs–the standard header of the site; another one the standard table, and so on.

The Reasoning Behind Templates

While that process is certainly valid and useful, most developers agree that the separation of business logic and layout logic makes the code a lot easier to understand and maintain. This is the reason behind templates, to separate business logic from layout.

What Smarty Has to Offer

Smarty is a somewhat new development in the PHP world, and it brings several new and unique features. One of these unique features is that Smarty ‘compiles’ the parsed templates into PHP scripts, and then reuses the compiled template when appropriate. Obviously, this brings a huge performance improvement over other template solutions, as the main PHP script doesn’t need to parse and output the same template on every request.

Smarty also has support for plug-in modules, allowing developers to create their own set of special functions and have Smarty recognize them. And it has built-in caching support, special constructs that can be used on templates to control the format of the layout, and much more.

Most importantly, Smarty gives developers tools that let them separate the business-logic code from the layout-formatting code. And Smarty goes one step further by allowing developers to put control-flow structures in the template source. This might sound a bad idea, since it would imply business-like logic in the template, but it is actually quite useful–you can tell Smarty to use a specific color on table X on the template itself, instead of having PHP code do this work. After all, this is template-related information.

One quick template example might be of value after this quick introduction:

{include file="header.tpl.html"}

Welcome to my Web site!

IP Address: {$smarty.server.REMOTE_ADDR}

{include file="footer.tpl.html"}

Installing Smarty

Smarty is quite simple to install, and I’ll give step-by-step instructions on how to do just that. First, you must download the distribution.

After downloading and extracting the files from the tarball, copy the resulting Smarty directory to some place inside your include_path. A good option is to copy this directory in the PEAR library directory (see my previous articles about PEAR). In Unix environments, it will usually be:

$ cp -R Smarty /usr/local/lib/php/

In Windows computers, you will need to copy the Smarty directory to ‘C:\php\pear’.

Organizing Your Application to Use Smarty

There are several ways to organize your application to make use of Smarty, but I’ll document here what I always do to structure my Web sites and applications.

My directory structure is as follows:

  configs (directory)
  templates (directory)
  templates_c (directory)

Make sure to give the Apache user write access to the templates_c subdirectory. This is the directory that Smarty uses to store the compiled templates. You can do this by using the following commands in a Unix system:

$ mkdir templates_c
$ chown nobody:nobody templates_c
$ chmod 700 templates_c

Please note that I’m assuming that the Apache user is nobody, so you should change the line above accordingly.

Read More

Joomla – A free and open source content management system (CMS)


by joomla.org

What is Joomla?
Joomla is an award-winning content management system (CMS), which enables users to build Web sites and powerful online applications. Many aspects, including its ease-of-use and extensibility, have made Joomla the most popular Web sites software available. Best of all, Joomla is an open source solution that is freely available to everyone.

History of Joomla
Joomla is the result of fork of Mambo on August 17, 2005. At that time, the Mambo name was trademarked by Miro International Pvt Ltd, who formed a non-profit foundation to fund the project and protect it from lawsuits. The joomla development team has created a web site called OpenSourceMatters.org to distribute information to users, developers, web designers and the community in general. Until now, Joomla has developed through various versions, such as Joomla! 1.0.0, Joomla! 1.5.21 and Joomla 1.6.

What can you do by Joomla?
Generally speaking, Joomla website brings together three elements: content, which is mainly stored in database; template, which controls the design and presentation of your content (such as fonts, colors and layout); Joomla, which is the software that brings the content and the template together to produce web pages.

Joomla is used all over the world to power Web sites of all shapes and sizes. For example:
Corporate Web sites or portals
Corporate intranets and extranets
Online magazines, newspapers, and publications

Advantages of Joomla
1. Advanced website technique. Joomla involves variety of website techniques, such as Web Cache Technology which can improve reaction and efficiency of website; and SEO (Search Engine Optimization) which is the basic technique of each website. This technique helps your website to be more easily found by users of search engine.
2. Simple and abundant operation interface. Even if you are not professional with website designing language, it is convenient for you to manage and compile articles on websites.
3. High flexibility of customize and system development.

Example of Joomla
1. Linux.com
2. iTWire.com

Outlook of Joomla
Joomla is the most popular open source CMS currently available as evidenced by a vibrant and growing community of friendly users and talented developers. Joomla’s roots go back to 2000 and, with over 200,000 community users and contributors, the future looks bright for the award-winning Joomla Project

HTML5 & CSS3 Open a New Chapter in Web Design Industry

by spinx web design

Most of the people in the web designing industry are aware the HTML stands for Hyper Text Mark-up Language while CSS stands for Cascading Style Sheets. These two languages are free, open source and compatible with all the browsers. These languages are search engine friendly and play an important role at indexing for the search engine list. The coding size is reduced by the CSS and this facilitates quick downloading. With reference to design and effect CSS is more flexible than HTML. The World Wide Web Consortium (W3C) has recommended these two languages for website designing and developing.

Nothing is constant except change. This principle is apt for HTML and CSS too. In the market one can find many versions of HTML and CSS. HTML version 4.01, version 4.0, version 3.2, and version 3 are already available in market while HTML 5 is in the making. The versions of CSS that are available in the market include CSS 3, CSS 2.1, CSS Level 2, and CSS Level 1.

IBM developed the first HTML language to aid the file transfer from one system to another. 1995 was the year when the HTML Version 2.0 was released, while the year 1996 saw the simultaneous release of HTML Version 3.2 and HTML Version 4.0. The World Wide Web Consortium released the XHTML 1.0 and XHTML 2.0. The first draft of HTML 5 was made ready in 2008. Most of the web development companies believe that the future of website designing is going to be dominated by HTML5 because it is going to most probably include features like video implantation void of separate codec or plug-in, separate threads in background for processing, canvas element, and offline access to email.

CSS is utilized to offer gorgeous style to the web page that is written with the help of a markup language. In 1996, W3C released CSS level 1. This was to prevail over the restrictions of HTML 3.2. The year 1998 saw the release of CSS level 2 that was created with the help of CSS level 1. In 1999 corrections were introduced in CSS level 1 and it was republished. CSS3 has been released to facilitate the service providers. This allows flexible and complex designs to be integrated into HTML. This technology is already being used by many custom web development service providers.

With passage the application of the internet and the utility along with relevance of websites is going increase exponentially. The technical and marketing complexities are going to increase. It is expected that the HTML 5 along with CSS will be successful at making things simple. It is sure that HTML5 is going to ride on the reputation its earlier versions.

Zend Updates PHP IDE, Framework for the Cloud

by Sean Micheal Kerner

PHP has long been used as one of the primary languages for the web. With the help of some new tools, commercial PHP backer Zend is now helping to position PHP for the cloud too.

At the ZendCon conference in Santa Clara, California, Zend today announced the general availability of the Zend Studio 8.0 IDE (define) and the Zend Framework 1.11 PHP application framework. Both the IDE and framework include new cloud-focused features and are part of a new PHP Cloud Application Platform ecosystem that Zend is now building.

"PHP was designed from the get-go just for the web," Andi Gutman, CEO of Zend said during his ZendCon keynote address. "Our goal is to solve web problems and that is what has made PHP so productive for web development."

One of the key tools used for PHP development is the Zend Studio IDE which is based on the Zend led Eclipse PDT (PHP Developer Tools) open source project. Eclipse PDT 2.2 was released in June as part of the Eclipse Helios project release cycle. Zend Studio 8 builds on top of Eclipse PDT with additional virtualization features for developers.

With Zend Studio 8, new integration with the VMware Workstation desktop virtualization solution is being provided to help the application development lifecycle of PHP apps. Gutmans noted that most Zend Studio developers build their apps on Windows or Mac and then deploy their applications onto a Linux production server.

"What the integration of VMware Workstation and Zend Studio enables you to do is to run Zend Studio on your Windows or Mac desktop and then run Zend Server in a Linux environment on your desktop that is as similar as possible to your production PHP server," Gutmans said.

Gutmans added that Zend Studio 8 knows which virtual machine it is connected to and if a file is saved, it will show up in the virtual machine instantly. He noted that the integration will help build a seamless develop, test and debugging experience with a production-like environment.

Zend Framework 1.11
Zend is also updating its Zend Framework PHP application framework to version 1.11 introducing new cloud capabilities.

With Zend Framework 1.11, Gutmans noted that the SimpleCloud API will be included which delivers a common API for cloud application deployments.

"The goal of SimpleCloud is to deliver a common API that enables you to leverage cloud application services such as storage and database," Gutmans said. "If you use the common API, your applications are actually portable across clouds."

With Zend Framework 1.11, new mobile support infrastructure to enable cross-platform device deployment is also being integrated. Gutmans noted that new mobile functionality will enable the framework to detect which mobile device is being used to access an application and what are the capabilities of the mobile device. He added that framework now includes view helpers to ensure that PHP applications are optimized for the specific mobile device that is being used to access an application.

Zend PHP Cloud Platform
Multiple Zend tools will be part of the upcoming Zend PHP Cloud Platform, which is intended to help enable a full application development and production lifecycle for cloud deployments. Gutmans did not state during his keynote when the Zend PHP Cloud Platform would be generally available.

A key part of the cloud platform will be an updated version of Zend Server PHP application server.

"A major feature that we’re missing in Zend Server is critical to enabling the cloud, and that’s application deployment," Gutmans said.

He added that in the upcoming Zend Server 6, developers will be able to integrate their development workflow with Zend Studio for cloud deployment. With Zend Studio, developers will be able to export their applications as a package and then deploy it onto a cluster with a high-performance deployment engine in Zend Server.

"As your application load goes up and we launch more servers to deal with the load, those servers will know to connect to the cluster manager and get all the applications deployed to it," Gutmans said. "All the deployment, scale-up and elasticity will work automatically with Zend Server."

LAMP-A Free and Open Source Web Development Platform

by Darren Wilkins

Since its advent the open source community has developed, and made accessible thousands of software, that have changed and significantly impacted the computing industry and the world as a whole. From software that run SCADA systems (Supervisory Control and Data Acquisition), embedded systems (in cars, air traffic systems, etc), cell phones, and medical equipment, the open source community has done it all. But one particular area in which open source software has had a significant impact is Web development. In previous years, when one engaged a discourse regarding the open source community’s impact on the World Wide Web, it typically gravitated toward the Apache Web server and/or other Web-related protocols. Today, open source Web development discourses are focused on a combination of free and open source software (FOSS) that now constitutes one of the best and most robust Web development platforms know as LAMP.

This article targets current and potential members of the Liberian Open Source Initiative (LIBOSI), the business community interested in establishing a Web presence, and IT professionals and students who have interest in Web development. My goal here is to introduce a FREE and OPEN SOURCE Web development platform that can be used to build a dynamic and robust Web presence, for government, businesses, schools, organizations, etc. In today’s IT environment, if an unemployed student or IT professional wanted to learn Web development using a proprietary platform like Microsoft.Net, he/she would have to spend hundreds of US dollars; an expense that an unemployed Liberian, or should I say most Liberians cannot afford. In this article, I will discuss LAMP (acronym explained later), a free and open source Web development platform. I place focus on the PHP programming/scripting language because it is my preference of language within the LAMP stack. My apologies to those who prefer the Perl and Python programming languages.

No, LAMP does not stand for Liberian Association of Married People! LAMP, in fact, is the acronym for Linux, Apache, MySQL and PHP/Perl/Python, with PHP being the most widely used programming language in the combination. Each component of the LAMP stack (Linux, Apache, MySQL, PHP/Perl/Python) is open source and available for free. The clause “open source and available for free”, means that anyone can use and modify each of the components in the stack as long as open source standards and principles are followed. It is important to note that not all open source software is free and not all free software is open source! The acronym LAMP was coined by Michael Kunze in a German magazine in 1998 when he tried to show that a bundle of free software could provide a viable alternative to commercial packages.

In the LAMP stack, Linux is the operating system and it was developed by Linus Torvolds while he was a student at the University of Helsinki. The most popular proprietary alternatives to Linux are Windows or Macintosh. Apache, developed by the Apache Foundation, is arguably the most commonly-used Web server. Its most popular proprietary competitor is Internet Information Server or IIS from Microsoft. MySQL is a relational database management system (RDBMS) with add-on tools for Web-based administration. It was developed originally by Michael Widener and named after his daughter, My. MySQL’s most popular proprietary competitors are Microsoft SQL Server, Oracle, Informix, etc. PHP is a popular object-oriented scripting language. Programmers like it because of its ability to manipulate text streams with ease and efficiency, even when they originate from disparate (different) sources. It is not a difficult programming language to learn as is C/C++ or Python or other programming languages. PHP is a very forgiving, flexible and easy to learn language.

There are also other Web development stacks such as Apple Computer’s WebObjects, Microsoft’s .NET and Java/Java EE architecture. Yet, these are all proprietary Web development platforms that may not be affordable to an individual or small business that needs a dynamic Web presence.

LAMP provides a lot of benefits including: flexibility, ease of development, customization, ease of deployment, security, and an enthusiastic community of supporters (CoS). Be that as it may, LAMP has not gained the market strength to dominate Microsoft .NET or Java platforms. Despite this, it is, and will continue to be deployed along with proprietary software to build dynamic and interactive Web sites. Currently several combinations of proprietary and open source Web development tools are being used in the enterprise. Linux, Apache and MySQL are combined with Java to form a LAMJ platform. Windows on the other hand, combined with Apache, MySQL and PHP/Perl/Python to create the WAMP platform. What this essentially implies is that for now, we will not see any single Web platform dominate the market as we have seen with Microsoft’s Windows operating systems. J2EE, LAMP, .NET, and others will be around and used based on the requirements of end-users. But whatever the operating system used, a combination of a Web server (Apache), dynamic components (using Perl, Python or PHP), and a database (MySQL), can allow a developer to create a truly database-driven and dynamic Web site that is easy to update and provides rich functionality to support users.

Personally, I use LAMP to run three applications: Moodle (Course Management System), Oscommerce (E-commerce) and Drupal (Content Management System). My experience building Linux servers that run these platforms forces me to boldly inform my reader that while LAMP is not actually difficult to learn, install, configure and administer, it does require a lot of work, time, and focus. Basically, if you are a “point and click” person who hates command line interfaces (CLI), coding or scripting, you may want to consider an alternative and more user-friendly platform.

Another thing worth mentioning is since there are over 300 distributions of Linux (Ubuntu, SuSe, CentOS, Fedora, Debain, Redhat, etc), installation can be challenging. Carrying out some operations running different Linux versions may require the execution of different actions. This is because different Linux distributions store files in different locations, use different commands to complete one and the same task, and so on. For example Ubuntu may have its “www” sub-folder in the “VAR” directory, while other distributions might store the “www” folder in another directory. And then there are several different types of downloads and installation methods; some involve the use of APT (UBUNTU) others aim for RPM (Redhat), Deb (Debian), YUM (Fedora), TAR, and so on. Initially, this makes it difficult for the novice IT professional. The bottom line is when doing a LAMP installation, you must pay close attention! But overall, LAMP provides a better alternative for people in developing nations like Liberia who are struggling to gain a place in the digital community.