Php Architect
Total Page:16
File Type:pdf, Size:1020Kb
Licensed to: Rémy Dufour [email protected] User #8203 Licensed to 8203 - Rémy Dufour ([email protected]) CONTENTS JULY 2009 FEATURES 13 Continuous Integration With PHP Felix De Vliegher Keep Your Code on Track. 19 Writing Custom PHP Extensions Gwynne Amaya Raskind Get in on the Extension Action 24 Future PHP, Future Java? Mercel Esser Three ways to mix Java and PHP. 30 Extending OXID eShop with Custom Modules Vikram Vaswani Now You Can Get Exactly What You Want. 40 Yii: Flex Your Flash Jeff Winesett Yii Makes It Easy. COLUMNS Licensed to 8203 - Rémy Dufour ([email protected]) 4 Editorial Elizabeth Tucker Long 50 exit(0); Marco Tabini PHP's Future? The Seven Seas of Insanity 6 From the Cloud Ben Ramsey 51 ElePHPants! Services in the Cloud 10 Enterprise PHP Ivo Jansch Continuous Integration Background Download this month’s code at: 49 Security Roundup Arne Blankerts http://phparch.com/code Trust Me - I know What I'm Doing If you want to bring a PHP-related topic to the attention of the professional PHP community, whether it is personal research, company software, or anything else, why not write an article for WRITE FOR US! php|architect? If you would like to contribute, contact us, and one of our editors will be happy to help you hone your idea and turn it into a beautiful article for our magazine. Visit www.phparch. com/writeforus.php or contact our editorial team at [email protected] and get started! EDITORIAL PHP's Future? July 2009 by Elizabeth Tucker Long Volume 8 - Issue 7 Publisher he theme for this issue is “The Future Arbi Arzoumani of PHP.” We could not have asked for a more abstract and wide-open theme. T Editor-in-Chief So what is the future of PHP? A staple in Elizabeth Tucker Long the enterprise scene? Wider use on the Windows platform? No one knows. The Author Liaison future of PHP could be anything because it Elizabeth Naramore is only limited by our imaginations, and as a Cathleen MacIsaac community, we are very creative (perhaps a little too creative sometimes). However, we had to pick a few topics for you, so I hope Technical Editors Simon Harris, Keith Casey, you enjoy reading about why you can benefit from Continuous Integration with Ivo, and once you know why you need it, head over to Felix’ article Clark Everetts, Luke Giuliani, on how to implement Continuous Integration. Marcel talks about merg- Jonathan Stark ing PHP and Java to give your code the ultimate portability, and Vikram introduces us to a shopping cart system that is designed to be customized Graphics & Layout and extended to fit your every whim. Jeff makes incorporating Flash in your Arbi Arzoumani site a snap with the Yii framework, and Ben shows you the affordable side of cloud computing. Sometimes PHP just isn’t enough. When that happens Managing Editor to Gwynne, she writes her own extensions using the Zend Engine, and this Arbi Arzoumani month, you’ll learn how you can too. Arne gives us a lesson in unrealized security risks, and of course, Marco wraps us up with a discussion about his Authors own warped mind. Arne Blankerts, Marcel Esser, Ivo Jansch, Ben Ramsey, Gwynne Amaya Raskind, Marco Tabini, Vikram Vaswani, Felix De Vliegher, Jeff Winesett Licensed to 8203 - Rémy Dufour ([email protected]) php|architect (ISSN 1709-7169) is published twelve times a year by Marco Tabini & Associates, Inc., 28 Bombay Ave., Toronto, ON M3H1B7, Canada. Although all possible care has been placed in assuring the accuracy of the contents of this magazine, including all associated source code, listings and figures, the publisher assumes no responsibilities with regards of use of the information contained herein or in all associated material. php|architect, php|a, the php|architect logo, Marco Tabini & Associates, Inc. and the MTA Logo are trademarks of Marco Tabini & Associates, Inc. Contact Information: General mailbox: [email protected] Editorial: [email protected] Sales & advertising: [email protected] Printed in Canada Copyright © 2003-2009 Marco Tabini & Associates, Inc. All Rights Reserved 4 | July 2009 www.phparch.com Licensed to 8203 - Rémy Dufour ([email protected]) COLUMN From the Cloud Services in the Cloud by Ben Ramsey Need to scale your web application but finding the cost of physical services too much for your budget? Cloud services may be just the answer for you. hat is cloud computing? Well, loosely put, it’s Amazon Elastic Compute Cloud any form of computing that takes place over a Amazon Elastic Compute Cloud, or EC2, takes the Wnetwork. More well-defined, it’s the practice concept of virtual private servers to a new level. With of offloading expensive processes to a machine or EC2, Amazon provides a cloud in which users may run pool of machines, scaling to any number of machines any number of virtual machine (VM) images with vary- depending on resource utilization. Historically, cloud ing degrees of resources allocated to each machine. Licensed to 8203 - Rémy Dufour ([email protected]) computing has been limited to use in the enterprise Each image running in the cloud looks and behaves due to the prohibitive expense of running tens of hun- just like a real server running in a server farm. This is dreds of machines, or even thousands of machines, to process data. The costs include hardware, electricity, space, and more, making it impractical for any small- to medium-sized business, but these obstacles are no RELATED URLs longer a problem with the advent of cloud services such as Amazon Elastic Compute Cloud (EC2), Windows • Amazon Elastic Cloud Compute (EC2) - Azure, and Google App Engine. http://aws.amazon.com/ec2/ Small, medium, and large businesses are now saving • Google App Engine - money by ditching their in-house, data-processing, http://code.google.com/appengine/ server farms and moving to these cloud services for • Azure Services Platform - everything from processor-intensive number crunching http://www.microsoft.com/azure/ to easy-to-scale web hosting. It’s a growing industry, • Scalr - http://code.google.com/p/scalr/ and more and more of the services we use on the Web • PHP on App Engine - http://phpwithjava.appspot.com/ are trusting their business models to external cloud computing services. 6 | July 2009 www.phparch.com From the Cloud COLUMN very attractive to businesses who rely on racks upon In addition, App Engine imposes some hard limits racks of machines in a data center. With virtualization, for the service, including a maximum of thirty seconds these business can greatly reduce costs by switching per request, 1,000 files per application, a maximum of to EC2, getting rid of hardware, cutting energy costs, 10 MB allowed in an HTTP response, and no more than and freeing up space. 1 MB per item stored in the data store. Other restric- For persistent storage, EC2 connects to Amazon tions include: read-only access to the file system, Simple Storage Service, or S3. For content distribution, execution of code only through an HTTP request, and Amazon CloudFront provides edge locations to speed data store queries are limited to only 1,000 rows re- up delivery of files to end users. Amazon Web Services turned per call. provides a full and flexible cloud-computing solu- While there certainly appear to be a lot of limita- tion, but this flexibility comes with a price: the user tions and restrictions involved in using App Engine, it is in full control and must manage his or her servers, can save you the hassle of managing a server farm. Use program them to scale properly, and set everything up App Engine when you don’t want to worry with server just as one would do with a real server farm—without set-up and maintenance, you want an environment that the hardware. That is, EC2 is not managed hosting. already comes complete with helpful APIs and even a Your system admins will still have plenty of work to built-in web application framework, and you don’t mind keep them busy. programming in Python or Java. Other languages will Still, EC2 is cheap—about $73 USD a month for the be added in the future, perhaps including PHP. smallest VM at the time of this writing—and provides As a side note, it is possible to run PHP on App plenty of options, including multiple distributions of Engine with Quercus, a Java implementation of the Linux and Windows Server images, or the ability to cre- PHP language. Follow the “PHP on App Engine” link in ate your own, and software exists, such as Scalr, to aid the Related Links section for more information. in scaling a pool of machines in EC2. Use EC2 when you want total control over the entire Windows Azure environment in which your applications run, from A relative newcomer to the cloud game, the Azure the software that runs in the cloud (such as Apache, Services Platform from Microsoft is a collection of PHP, MySQL, etc.) right down to managing the virtual various services and APIs that exist in the Microsoft servers to scale based on load. If porting applications cloud. These services include Live Services, SQL already running across multiple servers, then EC2 is Services, .NET Services, SharePoint Services, and a good fit because, for the most part, you can image Dynamics CRM Services. The hosting and management those machines and move them directly into EC2 with environment in which these services live is called minimal changes. Windows Azure, which is described by Microsoft as a “cloud services operating system.” On top of this plat- Google App Engine form and on this operating system, Microsoft runs such Google App Engine differs from EC2 in that the Google services as Windows Live, Office Live, Exchange Online, cloud is a full development platform in which you run and others, and they have opened up the platform, Licensed to 8203 - Rémy Dufour ([email protected]) applications rather than deploy virtual machines.