Federico Cargnelutti

Simple is better than complex. Complex is better than complicated. | @fedecarg

Archive for May 2008

PHP Compiler for the .NET Framework

with one comment

Phalanger makes PHP first-class citizen in the .NET languages family. It gives PHP programmers the ability to benefit from both the ease-of-use and effectiveness of the PHP language and the power and richness of the .NET platform taking profit from the best from both sides.

I have to admit, I’m a big fan of .NET and Anders Hejlsberg, the lead architect of the team developing C#. That’s right, I said it! I’m a fan of .NET! Anders created an excellent programming language, which has a procedural, object-oriented syntax based on C++ and includes influences from aspects of several other programming languages, most notably Delphi and Java. C# and PHP have a lot in common, they are both simple, modern, object-oriented programming languages. In fact, a lot of C# programmers are familiar with PHP, and vice versa.

What is Phalanger?

Phalanger is a new PHP implementation introducing the PHP language into the family of compiled .NET languages. It provides PHP applications an execution environment that is fast and extremely compatible with the vast array of existing PHP code. Phalanger compiles PHP scripts into MSIL (Microsoft Intermediate Language) which can be executed by .NET or Mono runtime. This runtime executes MSIL code using JIT (Just-In-Time) compilation, which makes the execution far more effective than interpretation and significantly improves application speed.

Thanks to the Visual Studio 2008 Shell provided by Microsoft, you can now get Visual Studio with Phalanger for free.

Phalanger Features

  • Compiles PHP language to the MSIL (Microsoft Intermediate Language), which is a byte-code assembly used by the .NET CLR
  • Compiles PHP scripts directly to the .NET/Mono assemblies
  • Phalanger makes it possible to use any .NET object in PHP applications
  • Allows using .NET objects from the PHP language thanks to the PHP/CLR Language Extensions
  • Enables using libraries written in PHP from other .NET languages
  • Allows using .NET generics including writing and extending generic objects in the PHP language
  • Allows writing objects fully compatible with .NET languages (like C#) in the pure mode
  • Thanks to Phalanger you can use PHP for developing presentation layer on top of bussines logic written in C#

Tutorials

Written by Federico

May 31, 2008 at 4:27 pm

Posted in PHP, Programming

30 Useful PHP Classes and Components

with 70 comments

Simplicity and extensibility are the main reasons why PHP became the favourite dynamic language of the Web. In the last decade, PHP has developed from a niche language for adding dynamic functionality to small websites to a powerful tool making strong inroads into large-scale Web systems.

Below I present 30 useful PHP classes and components that you can use to test, develop, debug and deploy your PHP applications. Let me know if I missed anything or if you have something to add.

Read the rest of this entry »

Written by Federico

May 29, 2008 at 10:39 pm

Posted in PHP, Programming, Tools

Version Control for Multiple Agile Teams

without comments

This article describes an example of how to handle version control in an agile environment with multiple teams. It’s not primarily targeted for version control experts, in fact such experts probably won’t find anything new here. It’s aimed at the rest of us, those of us that just want to learn simple and useful ways to collaborate. It may be of interest to anyone directly involved in agile software development, regardless of role, branching and merging is everybody’s business, not just the configuration manager.

Version Control for Multiple Agile Teams, another great article written by Henrik Kniberg.

Written by Federico

May 26, 2008 at 6:11 pm

Cygwin, a Linux-like environment for Windows

with one comment

If you are an experienced Linux user who misses a powerful command-line environment in Windows, you will enjoy Cygwin.

What is Cygwin?

Cygwin is a set of powerful tools to assist developers in migrating applications from Linux to the Windows platform. Cygwin delivers the open source standard Red Hat GNU gcc compiler and gdb debugger on Windows. In addition, it provides for a standard Linux development environment on Windows including APIs and command shells.

What can Cygwin do?

With Cygwin, Windows users can easily run shell command scripts, ls, cat, grep, sed, awk, etc. Standard Windows command line tools can even be intermixed within the Linux shell script environment to administer the Windows system. Over the years, Linux system administrators have developed a large toolbox set of management scripts for their Linux machines. Cygwin provides the ability to continue using these scripts on Windows machines.

Why use Cygwin?

One of the largest problems developers face today is supporting their applications on disparate platforms. Windows workstations continue to be added to an environment already populated by Linux and other UNIX-based Operating Systems. Using Cygwin, developers can manage heterogeneous environments in a consistent, efficient way.

Installing Cygwin

First go to Cygwin’s site and select Install or update now. This will download their online installer, setup.exe. The rest will be downloaded by the installer itself.

  1. Start the installer. Click Next.
  2. Choose Install from Internet. Next.
  3. Choose root directory, keep it as it is. Next.
  4. Choose local package directory, should be the desktop as default. Next.
  5. Choose connection. If you are behind a firewall, change the settings. Next.
  6. Choose location.
  7. Choose packages.
  8. The files are now downloaded from Internet and installed.
  9. When done click the finish button.
  10. To see that the installation works, click the shortcut that was made on the desktop.
  11. A console window is opened, showing some text.
  12. Close the console window.

Tutorials

An introduction to Cygwin
Cygwin, changing the face of Windows
Cygwin Website

Written by Federico

May 25, 2008 at 1:01 am

Posted in Linux, Programming, Tools

Virtual Appliances: LAMP development made easy

with 3 comments

The LAMP stack of open-source software, which includes the Linux operating system, Apache Web server, MySQL database, PHP and Python, has pushed its way into mainstream corporate software development. In this article I will show you why the LAMP platform has become the platform of choice for the development and deployment of high performance Web applications.

To get a LAMP development environment fired up without the hassles of configuring everything from scratch you only need one thing, a Virtual Appliance.

What is a Virtual Appliance?

A Virtual appliances is a pre-built, pre-configured, ready-to-run enterprise applications packaged with an operating system inside a virtual machine (I’m using Ubuntu 8.04). Virtual appliances are changing how Web applications are developed, distributed, deployed and managed, and they have many obvious benefits for developers.

Reasons for using a Virtual Appliance

  • For developing and testing Web applications on multiple platforms.
  • For quickly rolling back changes to a known state or creating a “read-only” environment.
  • For internal deployment of custom Web applications.
  • For customer demos during the sales process.
  • For training employees and customers.
  • For creating a flexible and open development environment whilst keeping the primary OS compliant with a locked down IT policy.

Now that you’ve learned about the benefits of using a virtual appliance, it’s time you try it out and experience it yourself.

Getting Started

1. Set up a development environment

1.1. If you don’t already have a VMware virtualization solution installed, download VMware Player for free.

1.2. Download a virtual appliance: Ubuntu 8.04 Desktop (568 MB) or Ubuntu 8.04 Server (256 MB).

1.3. Unzip the ZIP file and double-click the .vmx file.

2. Install Software

2.1. Install the LAMP stack. In Ubuntu 8.04 you can use Tasksel:

$ sudo tasksel install lamp-server

If you need help configuring Apache, visit this page.

2.2. Install the Zend Framework package. With the release of Hardy, the Ubuntu repositories now include a package for the Zend Framework, so you can have just one copy of the library on your server that is automatically updated.

$ sudo apt-get install zend-framework

This will install the Zend Framework in:

/usr/share/php/libzend-framework-php

3. Have fun

Enjoy your new Virtual Appliance, and welcome to the wonderful world of LAMP!

Written by Federico

May 24, 2008 at 12:55 pm

Open-source PHP applications that changed the world

with 65 comments

From managing databases to shopping, writing blogs to sending emails. Ten years of passion, great software architectures, team work and revolutionary ideas. Here are the most influential open-source PHP applications to date:

1998

phpMyAdmin

phpMyAdmin is a tool written in PHP intended to handle the administration of MySQL over the Web. Currently it can create and drop databases, create/drop/alter tables, delete/edit/add fields, execute any SQL statement, manage keys on fields, manage privileges, export data into various formats and is available in 50 languages. Development is backed up by the phpMyAdmin team.

1999

SquirrelMail

SquirrelMail is a standards-based Webmail package. It includes built-in pure PHP support for the IMAP and SMTP protocols, and all pages are rendered in pure HTML 4.0 for maximum compatibility across browsers. It has very few requirements, and is very easy to configure and install. It has all the functionality you would want from an email client, including strong MIME support, address books, and folder manipulation.

PHP-Nuke

PHP-Nuke is a Web portal and online community system that includes Web-based administration, surveys, access statistics, user customizable boxes, a themes manager for registered users, friendly administration GUI with graphic topic manager, the ability to edit or delete stories, an option to delete comments, a moderation system, referer tracking, integrated banner ad system, search engine, backend/headlines generation (RSS/RDF format), Web directory like Yahoo, events manager, and support for 33 languages and 9 database servers.

2000

eZ Publish

eZ Publish is an Enterprise Content Management platform with an easy to use out of the box Web Content Management System. It is available as a free Open Source distribution and serves as the foundation for the rest of the eZ Publish Product Family. As a CMS it’s most notable feature is its revolutionary, fully customisable and extendable content model. It is also a platform for general web development, allowing you to develop professional PHP applications. Standard eZ Publish functionality: easy to create and edit content, workflow system, content versioning, multilanguage possibilities, collaboration, e-commerce functionality, revolutionary content class system, role based access control are implemented and ready for you to use. High quality software and total product responsibility from eZ systems make eZ publish the leading Open Source Enterprise Content Management System. Enterprises, governmental offices, organizations and educational institutions trust eZ Publish.

osCommerce

osCommerce is an open source e-commerce solution under on going development by the open source community. Its feature packed out-of-the- box installation allows store owners to setup, run, and maintain their online stores with minimum effort and with no costs involved. osCommerce combines open source solutions to provide a free and open development platform, which includes the powerful PHP web scripting language, the stable Apache web server, and the fast MySQL database server.

OpenX

OpenX began as phpAdsNew, a fork from a similar project called phpAds, created by Tobias Ratschiller in 1998. OpenX is a hugely popular, free ad server designed by web publishers for web publishers. It provides everything you need to manage your on-line advertising. It allows paid banners to be easily rotated along with your own in-house advertisements, and can even integrate banners from third party advertising companies.

phpBB

phpBB is a fast, efficient discussion board program built in PHP with a muti-database backend. Features include: posting, replying, private messages, polls, username/ip banning, strong encryption for storing passwords, user rankings, very advanced access control for private forums, full templating, simple yet robust translation system and much more.

2001

Gallery

Gallery is a slick Web-based photo album written using PHP. It is easy to install, includes a config wizard, and provides users with the ability to create and maintain their own albums in the album collection via an intuitive Web interface. Photo management includes automatic thumbnail creation, image resizing, rotation, ordering, captioning and more. Albums can have read, write, and caption permissions per individual authenticated user for an additional level of privacy.

Drupal

Drupal is a modular content management system, forum, blogging and community engine. It is database driven and can be used with MySQL, MySQLi and PostgreSQL. Its features include (but are not limited to) discussion forums, Web-based administration, theme support, a submission queue, content rating, content versioning, taxonomy support, user management with a fine-grained permission system based on user roles (groups), error logging, support for content syndication, locale support, and much more. It is considered to be an excellent platform for developers due to its clean code and extensibility, and it can also be used as a Web application framework.

2002

MediaWiki

MediaWiki is a web-based wiki software application used by all projects of the Wikimedia Foundation, all wikis hosted by Wikia, and many other wikis, including some of the largest and most popular ones. Originally developed to serve the needs of the free content Wikipedia encyclopedia, today it has also been deployed by companies for internal knowledge management, and as a content management system. Notably, Novell uses it to operate several of its high traffic websites.

2003

WordPress

WordPress is a state-of-the-art, semantic, personal publishing platform with a focus on aesthetics, Web standards, and usability. It was born out of a desire for an elegant, well-architected personal publishing system. While primarily geared towards functioning as a Weblog, WordPress is also a flexible CMS capable of managing many types of Web sites. In addition to the basic blog functions, it also has an integrated link manager (e.g. for blogrolls), file attachments, XFN support, support for stand-alone pages, Atom and RSS feeds for both content and comments, blogging API support (Atom Publishing Protocol, Blogger, MetaWeblog, and Movable Type APIs), spam blocking features, advanced cruft-free URL generation, a flexible theme system, and an advanced plugin API.

2004

SugarCRM

SugarCRM is a complete CRM system for businesses of all sizes. Core CRM functionality includes sales force automation, marketing campaigns, support cases, project mgmt, calendaring and more. Built in PHP, supports MySQL and SQL Server.

2005

Joomla!

Joomla! is an award-winning Web-based content management system. It provides for split front end content access and backend administrator access. Group-based access control allows for different levels of system control for both the site and the administrator. The Joomla! framework allows for extension by installable components (applications), modules (template blocks), languages, templates, and mambots (plugins that enhance system functions).

Symfony

Symfony is a full-stack framework, a library of cohesive classes written in PHP5. It provides an architecture, components and tools for developers to build complex web applications faster. Choosing symfony allows you to release your applications earlier, host and scale them without problem, and maintain them over time with no surprise. Symfony is based on experience. It does not reinvent the wheel: it uses most of the best practices of web development and integrates some great third-party libraries.

Pligg

Pligg is an Open source Social Networking Content Management System (CMS) Combining social bookmarking, blogging, and syndication and a democratic editorial system enables users to collaboratively submit and vote articles. It was influenced by the extremely popular and proprietary software Digg, where when a user submits a news article it is placed in the “upcoming” area until it gains sufficient votes to be promoted to the main page.

2006

Zend Framework

Extending the art & spirit of PHP, Zend Framework is based on simplicity, object-oriented best practices, corporate friendly licensing, and a rigorously tested agile codebase. Zend Framework is focused on building more secure, reliable, and modern Web 2.0 applications & web services, and consuming widely available APIs from leading vendors like Google, Amazon, Yahoo!, Flickr, as well as API providers and cataloguers like StrikeIron and ProgrammableWeb.

2007

Magento eCommerce

Magento is a new professional open-source eCommerce solution offering unprecedented flexibility and control. It was designed with the notion that each eCommerce implementation has to be unique since no two businesses are alike. Magento’s modular architecture puts the control back in the hands of the online merchant and places no constraints on business processes and flow.

eyeOS (Cloud Computing OS)

eyeOS is an open source web desktop following the cloud computing concept that leverages collaboration and communication among users. It is mainly written in PHP, XML, and JavaScript. It acts as a platform for web applications written using the eyeOS Toolkit. It includes a Desktop environment with 67 applications and system utilities. It is accessible by portable devices via its mobile front-end.

2008

Laconica

Laconica is an open source microblogging server that implements the OpenMicroBlogging standard for interoperation between installations. While offering functionality similar to Twitter, StatusNet seeks to provide the potential for open, inter-service and distributed communications between microblogging communities. Enterprises and individuals can install and control their own services and data.

Elgg

Elgg is a open source social networking platform. It offers blogging, networking, community, collecting of news using feeds aggregation and file sharing features. Everything can be shared among users with access controls and everything can be cataloged by tags as well.

PHPmotion

PHPmotion is a free video sharing software that also has support for other types of media such as audio/mp3 sharing. The Content Managent System or (media cms application) will allow you to create and run your very own Video Sharing website, Music Sharing Site, Picture Sharing Site. With very little knowledge required you can now have a website just like YouTube, DailyMotion, Veoh, hi5 and other proprietary applications. Best of all, its 100% free to download and use.

2009

Piwik

Piwik aims to be an open source alternative to Google Analytics. Piwik is a software that you download and install on your own webserver. At the end of the five minute installation process you will be given a JavaScript tag. Simply copy and paste this tag on websites you wish to track, or use an existing plugin to do it automatically for you.

Open Atrium

Open Atrium is a platform for building team portals that can be extended to meet highly custom knowledge management needs for large organizations’ intranets and extranets. It starts with “out of the box” features like a blog, a wiki, a calendar, a case tracker, a shoutbox, and a dashboard to manage content. These features can be expanded to meet unique needs for large organizations so that full scale enterprise collaboration sites can be built with Open Atrium as a base. By fully leveraging Drupal, all of the strengths of Drupal can contribute to creating custom features for Open Atrium within a framework that is already tailored for team collaboration.

Written by Federico

May 22, 2008 at 8:13 pm

Posted in PHP, Programming, Tools, Web

Service-oriented Architecture

with one comment

My girlfriend finally understood what Service-oriented Architecture is:

http://www.youtube.com/watch?v=dyHWAiG6c-Y

Written by Federico

May 21, 2008 at 8:42 pm

PHP NetBeans IDE 6.1 is in the house!

with 7 comments

By now, most PHP programmers have heard of Eclipse, the extensible open source development platform that is rapidly becoming the most popular IDE for PHP programming. However, some developers have never heard of NetBeans before. Feature-for-feature, Eclipse and NetBeans are well matched. In fact, because they are both extensible, any feature gaps between the two can be filled in with third-party plug-ins.

Eclipse and Netbeans are rapidly approaching the capabilities of commercial offerings. Most developers won’t need more than what these two excellent development platforms provide.

Comparing NetBeans and Eclipse

The most recent versions of these two IDEs have far more similarities than differences. They both have syntax checking, code completion, and code folding. They both let you run and debug your code. They both support Ant, SVN, and Unit Testing.

NetBeans IDE 6.1 Features
NetBeans Download

Written by Federico

May 20, 2008 at 5:39 pm

Posted in PHP, Programming, Tools

Managing and applying database changes with LiquiBase

with 3 comments

LiquiBase is an open source, DBMS-independent library for tracking, managing and applying database changes. It is built on a simple premise: All database changes (structure and data) are stored in an XML-based descriptive manner and checked into source control.

Adding a changeset

<?xml version="1.0" encoding="UTF-8"?>

<databaseChangeLog
  xmlns="http://www.liquibase.org/xml/ns/dbchangelog/1.6"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog/1.6
         http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-1.6.xsd">

    <changeSet id="1" author="bob">
        <createTable tableName="department">
            <column name="id" type="int">
                <constraints primaryKey="true" nullable="false"/>
            </column>
            <column name="name" type="varchar(50)">
                <constraints nullable="false"/>
            </column>
            <column name="active" type="boolean" defaultValue="1"/>
        </createTable>
    </changeSet>

</databaseChangeLog>

Running the ChangeSet

There are many ways to execute your change log including via command line, Ant, Maven, Grails, etc.

liquibase --driver=com.mysql.jdbc.Driver \
--classpath=/path/to/classes \
--changeLogFile=com/example/db.changelog.xml \
--url="jdbc:mysql://localhost/example" \
--username=user \
--password=asdf \
migrate

Done!

You will see that your database now contains a table called “department”. Two other tables are created as well: “databasechangelog” and “databasechangeloglock”. The databasechangelog table contains a list of all the statements that have been run against the database. The databasechangeloglock table is used to make sure two machines don’t attempt to modify the database at the same time.

LiquiBase Website

Related Articles

Written by Federico

May 19, 2008 at 6:05 pm

13 reasons why UML failed

with 4 comments

One of the reasons is that UML attempts to become a programming language.

By aiming to be able to generate full code actually UML tries to be a programming language. In my mind there is a big problem with a general purpose graphical programming language. In human history the written form of all languages evolved from graphical to textual (see also Visual Designs Don’t Scale). Alphabets proved to be more versatile and more expressive than pictures in capturing ideas. Try to describe any simple process in images. The funny thing is you still have to annotate the images with words. And the full text version with no pictures still gives you more details. Pictures prove to be good at sharing ideas and allowing people to visualize concepts. But in the end words are better at describing the fine details.

Read more

Written by Federico

May 17, 2008 at 7:55 pm