December 11, 2006

Regular Expression Tester

You will find other articles relevant to this document in these sections:
Richard Lee @ 2:18 pm

Regular Expressions are tricky at the best of times, wouldn’t it be great if you could test your patterns ? - Well you can -  Checkout this handy online tester http://www.quanetic.com/regex.php

November 29, 2006

Working with dates in PHP and MySQL

You will find other articles relevant to this document in these sections:
Richard Lee @ 9:57 am

Here’s some quick examples of a few different ways you can work with  date/ or datetime fields rom a MySQL database. Hope you find them helpful :)
Formatting date with MySQL for output:

$query = mysql_query("SELECT DATE_FORMAT(event_date, '%d/%m/%y') AS formatted_date FROM events");
 
$row = mysql_fetch_array($query);
 
echo $row['formatted_date'];
// output: 20/11/06

Retrieving a date from MySQL with the intention of using it for calculation (timestamp conversion):

$query = mysql_query("SELECT UNIX_TIMESTAMP(event_date) AS timestamp FROM events");
 
$timestamp = mysql_fetch_array($query);
 
echo $row['timestamp'];
// output: 20061120091528 i.e. 2006-11-20 09:15:28

Formatting a date string with PHP for output:

$query = mysql_query("SELECT event_date FROM events");
 
$row = mysql_fetch_array($query);
 
$formatted_date = date('d m y', strtotime($row['event_date']));
 
echo $formatted_date;
 
// output: 20/11/06

Converting formatted date strting for calculation in PHP (timestamp conversion):

$query = mysql_query("SELECT DATE_FORMAT(event_date, '%d/%m/%y') AS formatted_date FROM events");
 
$row = mysql_fetch_array($query);
 
echo 'Formatted date: '.$row['formatted_date'];
 
//output : 20/11/06
 
$timestamp = strtotime($row['formatted_date']));
 
echo 'Timestamp '.$timestamp;
 
// output: 20061120091528 (i.e. 2006-11-20 09:15:28)

November 22, 2006

Zend Certifications for PHP5

You will find other articles relevant to this document in these sections:
Cameron Manderson @ 10:38 pm

I have recently been reading my subscription of php|architect and been reading about the new Zend PHP5 certifications. As I have been recently revisiting other areas of development (Spring/Hibernate etc) I have decided to gain my certification as a Zend Certified Engineer in PHP5 (or a ZCE) as a way to feel that I have accomplished a recognised firm understanding before seeking new areas of research/certifications. Gaining a broad recognition into different technologies is required to have the edge these days (see my recent post on Developer skills outlook for 2007 and beyond) and being able to play around with Java/PHP/C#/AS3 etc is the aim.
In preperation I have ordered the php|architect’s Zend Certification Study Guide and have a few weeks before I receive it. Just for a play I jumped on the PHP Education - Zend PHP Certification Self Test and it tells me I am ready to go for the certification test with a quick score of 6/8 (oops, probably should have probably taken a few more time to read the questions). php|architect also offers mock tests that will help prepare you before sitting the real exam which apparently are extremely similar to the real format and is used to help identify any other areas you need to focus on [Webservices/XML or whichever].
Some of the other boys at work are getting the Adobe Certification (I think is called ACE) in Flash Design/Development (good luck to Sacha, Marcus, Andy and Simon in their upcoming exams!). Having a play around with ActionScript2/3 has been fun and we all have a research job at the moment in Flex2, of which I am creating a flexible format XML/XSD/DTD to power the presentation/connectivity. Having guys focus strongly on interface design and construction while coupling it with a powerful developer team implementing SOA through different (appropriate) technologies is definately a huge area of interest.

Advanced PHP Solutions with Zeev Suraski

You will find other articles relevant to this document in these sections:
Cameron Manderson @ 10:09 pm

Appearing on Zend Events:

PHP continues to enjoy phenomenal growth becoming the de-facto standard for enterprise Web applications. With the introduction of PHP 5, PHP has reached new levels of support for Web Services, XML and Service Oriented Architectures (SOA) meeting the robust demands of the enterprise environment. Learn how you can achieve scalability, performance, availability and reliability for your enterprise-class PHP applications with advanced PHP solutions from Zend Technologies.
Featured Speaker:

  • Zeev Suraski, Co-Founder and Chief Technology Officer, Zend Technologies

View Webcast

Microsoft and Zend Technologies announce Technical Collaboration

You will find other articles relevant to this document in these sections:
Cameron Manderson @ 10:06 pm

Announced at the end of October 2006 -

Microsoft Corp. and Zend Technologies Inc. today announced a technical collaboration to enhance the experience of running the PHP scripting language on Windows Server® 2003. The parties expect to extend the collaboration to the next version of Windows Server, code-named “Longhorn.” The resulting technology enhancements and ongoing interaction with the PHP community is expected to enable customers to take advantage of the Windows Server platform. The cooperative effort seeks to provide customers with richer functionality and better integration, resulting in improved performance and increased reliability.

Click here for the article

November 8, 2006

Adobe FDS2 - US$20K

You will find other articles relevant to this document in these sections:
Cameron Manderson @ 10:13 am

Looking through the Adobe website I came across the pricing structure for the Flex Data Services 2 framework, the enterprise edition costing $20K per CPU. A budget that would be un-achievable to most, and even in a high-load website, you will most likely have to setup a clustered environment, meaning that you will most likely be up for more than one licence. Ouch!
So where does that leave us? We can consider the other technologies that are available, including XML and WebServices. Both work in plain text XML which works like a dream for small data transfer, but you quickly consider the amount of formatting and XML document places around the data and often the formatting takes up a lot of the file size, bloating it out. (This may be remedied slightly through GZip compression over HTTP, but I need to investigate…).

So if we still want Flash Remoting without the price tag where do we turn? - Open Source

Quoting a recent article I read I have often heard people claim “Companies do not invest into open source technologies” which I think is pretty wrong. A quote obtained from a recent article with Rasmum Lerdorf (a developer of open source technologies - PHP) when asked about ‘The Open Source movement is still portrayed by many as “anarchistic” and some kind of “threat to society”‘ :

As far as being mainstream, the product of this “movement” is most definitely mainstream. The “movement” built the Internet as we know it today. It built the TCP/IP stacks used in most of the operating systems people use (yes, even Windows). It built the most popular Web server in the world, along with the DNS and MTA systems that make the Internet tick. Heck, if you go back a bit, it built the entire industry. The first operating systems were all open source, because that was the only sane way to do things. You could not sell someone a big mainframe without providing the source to the brains of the thing. It was only later on that the concept of not providing the source code was introduced.

But I guess your real question is what I think of Microsoft’s attempt to convince the world that large groups of people collaborating to solve problems somehow threatens the very fabric of the society we live in. And I don’t think there are “many” people making this claim, as it is complete crap — I would like to think that the world is a good place and not full of people who would propagate such a ridiculous idea. Let’s put an end to all meetings of large groups of people while we are at it. They might be evil anarchists out to destroy the world.

In the end, mainstream acceptance is not the goal. The goal for most people who work on free software and open source projects is the technology itself. It is building a tool that solves the problem. It is not about ideology for most of us, and as such, mainstream acceptance only involves mainstream use of the technology. This has been achieved on many fronts already, with many more still to come.

Getting past the whole Corporate versus Community conversation and moving on;

PHP as a thin layer provides great database layering, with a nice framework AMF-PHP which could handle basic output to flex. This framework works great, but still has around 40-50ms class instantiation cost per request (which may be considered pretty low, and can be tuned with APC). Making the move to a JEE environment means that we can handle database queries through a JDBC environment, bringing JDBC equivalent database into PHP means more overhead, and unless you go that path it makes it more difficult to make your whole project scalable. But discussing PHP and JEE performance is not the point of this article, we are talking about alternatives.
OpenAMF is a JEE alternate to the Flash Data Services offered by Adobe. I found a nice little introduction to openAMF with this article. Although a slightly bloated introduction regarding JEE, PHP and ActionScript it is still relevant to conversations we have been starting on this blog, such as “Where does PHP really sit?

One of the cumbersome of using Java is the relatively complex setup of Java applications, with different steps based on the container. J2EE helps on this, exposing a more standard framework to follow for web developers. Also Java is not a common shared hosting offer, and this make sense because the power of java and his multithread run shines in big applications or when a lot of traffic is expected, due also to the live of servlets in memory. Usually little-medium applications fits fine in more straightforward languages like PHP. So freelancers developers not involved in big corporations are not usually faced to Java, and it’s a shame, because it’s a great language. But the grow of ActionScript from AS1 to AS2 force coders to write in a more Java-like (or should say OOP-like) way, so Java seems more familiar to them. And AS3 will reinforce this being a really truly class based language (in fact, not compatible with previous versions of the Flash Player) All of this make the jump to Java less heavy for actionscript coders, at least with Java in relationship with Flash.

Being Java a wide field, probably Flash developers will be faced first in data exchange with Java. This could be done in many faces, in example name/value pairs could be solved with some jsp file, but the really power of data exchange is exposed trough Flash Remoting. Even java can map ActionScript classes to Java classes whit out problem, something that arises as a problem in the first implementations of other Remoting libraries like amfphp (last versions solve this) Also since the gateway runs as a servlet, is really fast in doing his work (except the first time of course).

You  can read more about AMF-PHP here for using PHP or take a look at JEE alternative OpenAMF.

November 7, 2006

Connection Pooling and Hibernate

You will find other articles relevant to this document in these sections:
Cameron Manderson @ 9:01 pm

Connection pools are a smart way of maintaining connections so that they can be reused when the database receives future requests for data. Reading through the Hibernate documentation, Hibernate explains that the connection pooling algorithm used as default by Hibernate is not adequate for production, and recommends the c3p0 open source database connection pool’er.

Hibernate’s own connection pooling algorithm is however quite rudimentary. It is intended to help you get started and is not intended for use in a production system or even for performance testing. You should use a third party pool for best performance and stability. Just replace the hibernate.connection.pool_size property with connection pool specific settings. This will turn off Hibernate’s internal pool. For example, you might like to use C3P0.

You can find the c3p0 project on Sourceforge from this URL: http://sourceforge.net/projects/c3p0

C3P0 is an open source JDBC connection pool distributed along with Hibernate in the lib directory. Hibernate will use its C3P0ConnectionProvider for connection pooling if you set hibernate.c3p0.* properties. If you’d like to use Proxool refer to the packaged hibernate.properties and the Hibernate web site for more information.

c3p0 is an easy-to-use library for augmenting traditional (DriverManager-based) JDBC drivers with JNDI-bindable DataSources, including DataSources that implement Connection and Statement Pooling, as described by the jdbc3 spec and jdbc2 std extension.

You can read about Connection Pooling on wikipedia, or read this documentation on how to configure hibernate to use c3p0.

As a note to PHP users, PHP creator Rasmus Lerdorf discusses about the lack of connection pooling in PHP (as well as all the other hard questions of PHP). People can check out SQLRelay as a way of helping implement connection pooling, but requires a server install.

SQL Relay is a persistent database connection pooling, proxying and load balancing system for Unix and Linux supporting ODBC, Oracle, MySQL, PostgreSQL, Sybase, MS SQL Server, IBM DB2, Interbase, SQLite and MS Access (minimally) with APIs for C, C++, Perl, Perl-DBI, Python, Python-DB, Zope, PHP, Ruby, Ruby-DBI, Java and TCL, drop-in replacement libraries for MySQL and PostgreSQL clients, command line clients, a GUI configuration tool and extensive documentation. The APIs support advanced database operations such as bind variables, multi-row fetches, client-side result set caching and suspended transactions. It is ideal for speeding up database-driven web-based applications, accessing databases from unsupported platforms, migrating between databases, distributing access to replicated databases and throttling database access.

November 5, 2006

Log4php - All your logging needs

You will find other articles relevant to this document in these sections:
Cameron Manderson @ 4:00 pm

People working with PHP applications should check out the PHP port of Log4j, the logger written originally for Java. We used to use this a long time ago with our Struts Java web applications, and the same functionality can be achieved using this, add it to your toolkit for your applications.

The port is provided by Apache and is available at the link: http://logging.apache.org/log4php/

November 2, 2006

PHP - Where exactly do you sit?

You will find other articles relevant to this document in these sections:
Cameron Manderson @ 11:43 pm

I read an article recently about more on the Zend and IBM partnership, which I have been aware of for some time, but hadn’t quite seen it phrased this way - PHP is to compete against .NET for SME web applications. For me that was a big ‘wow’ statement.

When researching technologies for enterprise application development I have seen often a lot of Java technologies such as JSF, Spring/Hibernate, Struts and Tapestry - yet I rarely see in the same article the emerging structures from PHP or .NET. It is like there is a bottom teir that  PHP, .NET and RoR falls into, great for lower level projects or specific implementations (such as rapid development with RoR and .NET, and speed and simplicity of PHP) . It has made me really think about how PHP lacks against the other technologies, and also trying to identify the best use for PHP - where does it end and others begin? If at all?
For me PHP has clearly been always a light-weight development tool that performs well. But it does lack a lot of enterprise level functionality, such as persistence layers and MVC frameworks and a useful class API (not just functions, but well structured classes/interfaces). This has sparked a lot of additional projects such as PEAR/Pecl which has aimed at providing additional class functionality. As a comparison I have seen .NET to have those parts of the application framework solved as part of its standard offer, and C# is great, but if you were to step up to that level you would be better off stepping into the JEE realm, as there is much more richness, developer focus, resources and technologies (personal preference) - and “it isn’t evil” as my old boss would say.

As a result taking the leap from PHP to JEE has been in the past quite large, and there is often debate in my mind where the line is between the projects. If you step up from PHP not only do you need a dedicated production environment (no adequate shared hosting in Australia) but you need to step the whole infrastructure of your applications up in their configuration. This has lead me down the path of introducing and leveraging off contributed frameworks for PHP, which have almost always been modeled off Java. Persistence layering homegrown, database abstraction ADOdb, MVC with php.MVC etc.

But once you start to build your aps and really press into these different packages you start to feel that you are just trying to implement concepts that have been around for 5+years in Java anyway, and hunders of developers are contributing to its stable releases and documentation. Also you then start to encounter overheads in loading of packages of PHP and then find you have to use cut down versions (such as ADOdb_lite etc) to try and pick up the performance back for your requests (as every request builds up and tears down). It feels like you are always trying to port framework ideas into PHP, when if you just took the next step up to JEE all your problems will be gone. But remember, dedicated production environment, bogus configurations, argh!

So I am interested to see what Zend and IBM start to introduce to make working for small to medium enterprise applications easier, without ending up creating a mix and match purpose driven dribble snippets of code, like a API to work with google, instead of dealing with creating a real set of structure that you can build off. Real sets of interfaces and classes to deal with first, then the nicer tricks built off the top.

So what things do I dig at the moment that are going on in the PHP world that will really excite where it is going?

- PDO - Formalising some structure behind database connectivity
- SDO - Single API for data, introducing concepts of Persistence and Object Relational Mapping
- XML - PHP5 with various additions of DOM, simpleXML etc - XML is great for almost everything
- Web Services - Ensuring future interoperability with larger parts of the application
Hopefully with the Zend Framework being developed on we will see more core structure and packages coming out dealing with collections, HTTP request objects and database etc, and then eventually see more application frameworks (MVC’s etc) being introduced. This may lead to a scenario where PHP can really sit into that small-medium project size, being able to be as simple as a Hello World web application in 1 line but still having the ability to scale into a medium app with MVC, abstraction and persistence. And, due to the XML and Webservices functionality provided in the newer PHP versions we will see PHP sit more and more definatively into its position in the industry.

October 30, 2006

T2Tea - Online tea, gifts and homewares shopping/ecommerce with Flash

You will find other articles relevant to this document in these sections:
Cameron Manderson @ 11:31 am

If any of you have been wondering where I have been or been upto leading up to October, it has been working on the new T2 Tea website.

T2 offers Australia’s largest range of beautiful, fragrant teas from around the world. The website offers ways to further create the experience offered in their award-winning stores; browse for teawares and learn the delicate art of brewing tea developed over many centruries.

The T2Tea website (powered by Radiant Logic PTY LTD we have won a IMA award) has been a completely revamped version of the 2005 XMas site we did last year, and has been redone completely in Flash. It allows visitors to interact with T2 through the web in completely new ways, through interactive tea selectors, learning how to brew and interactive shop creating a whole new experience for the visitor.

Working with the talented new media team at Carbon+ (now Rich Creative), Radiant Logic PTY LTD had the task of designing and developing the Ecommerce and Content/Product Management for the project, as well as creating a fast system for the Flash Designers and Developers to access and search the information, and, process orders, with zero impact on their design. Using Flash Remoting and my own developed Ecommerce and CMS products this developed the foundation to power the rich interface (RIA) architecture with zero impact on the design/presentation of the interface. Staff can quickly update all content, including products, news and pages, staff area, employment etc. The ecommerce system accepts online credit card transaction, calculated australia post shipping and optinal gift wrapping services as well. There was never a break across to HTML like many other Flash ecommerce sites, this site kept the user in the site the whole time while still providing a Safe Secure system for visitors to process their purchase orders online. The system saves time for various wholesaler and resellers by allowing ordering to occur online instead of a paper based system.
Please check out the site and have a browse of all the interactive features, I hope you enjoy:

http://www.t2tea.com.au/

NOTE: As well as this project I have been working on several other flash driven sites, all content managed, as well as another flash ecommerce project to be launched shortly. I will keep you posted.

« Previous PageNext Page »