Archive for 'PHP'
Interesting Zend Webinars for January

Interesting Zend Webinars for January

Posted 13 January 2010 | By vinu | Categories: General Stuff, PHP | No Comments

Here are some webinars from Zend which you may find interesting:

Webinar – PHP Development Best Practices: The Untold Story of Geekville
January 19, 2010 – 9:00 am PST – your computer via webex

Have you ever wondered how you could advance your PHP development? Have you considered using an Integrated Development Environment (IDE), an Issue Tracker or a Version Control tool, but were concerned about how complex it might be? Taking PHP development to the next level may be easier than you think.  Attend this webinar, hosted by Atlassian and Zend More Information/Registration

Webinar – Troubleshooting PHP Issues: Best (and Worst) Techniques
January 28, 2010 – 8:00 am PST – your computer via webex

Understanding what’s causing your PHP application to be slow or just break is often time-consuming, and almost always frustrating. Join this information-packed webinar, delivered by a senior Zend PHP consultant, to learn what techniques PHP professionals use for pinpointing PHP issues in development, testing and production. More Information/Registration

Reblog this post [with Zemanta]
PHP 5 Power Programming – Free Ebook

PHP 5 Power Programming – Free Ebook

Posted 12 January 2010 | By vinu | Categories: PHP | 2 Comments

Here’s a free PHP Ebook from Bruce Perens’ Open Source Series. More about this book:

In this book, PHP 5’s co-creator and two leading PHP developers show you how to make the most of PHP 5’s industrial-strength enhancements in any project—no matter how large or complex. Their unique insights and realistic examples illuminate PHP 5’s new object model, powerful design patterns, improved XML Web services support, and much more. Whether you’re creating web applications, extensions, packages, or shell scripts—or migrating PHP 4 code—here are high-powered solutions you won’t find anywhere else.

Review PHP’s syntax and master its object-oriented capabilities—from properties and methods to polymorphism, interfaces, and reflection

  • Master the four most important design patterns for PHP development
  • Write powerful web applications: handle input, cookies, session extension, and more
  • Integrate with MySQL, SQLite, and other database engines
  • Provide efficient error handling that’s transparent to your users
  • Leverage PHP 5’s improved XML support—including parsing, XSLT conversions, and more
  • Build XML-based web services with XML-RPC and SOAP
  • Make the most of PEAR: work with the repository, use key packages, and create your own
  • Upgrade PHP 4 code to PHP 5—compatibility issues, techniques, and practical workarounds
  • Improve script performance: tips and tools for PHP optimization
  • Use PHP extensions to handle files/streams, regular expressions, dates/times, and graphics
  • Create original extensions and shell scripts

If you’re a software developer new to PHP, you’ll leap quickly into PHP and its new object-oriented capabilities. If you’re an experienced PHP programmer, you already recognize PHP’s convenience and simplicity. Now, discover all of its extraordinary power!

Free Ebook download: Download PHP 5 Power Programming (PDF)
If you like this book and would like to order the Print book, check out Amazon’s deals on PHP 5 Power Programming.

Practical PHP Testing – Free Ebook

Practical PHP Testing – Free Ebook

Posted 04 January 2010 | By vinu | Categories: PHP | No Comments

If you’re new to testing in PHP, and were wondering how to create and run automated tests, here’s an ebook which will help you get the basics right.

Practical PHP Testing is an ebook which is a compilation of  articles from Giorgio Sironi’s blog on Practical PHP testing.

This book takes you though the basics of PHPUnit – how to install it and start writing simple tests using PHP Unit. Here are some of what this ebook covers:

  • bonus chapter on TDD theory;
  • a case study on testing a php function;
  • working code samples, some of whom were originally kept on pastebin.com;
  • sets of TDD exercises at the end of each chapter;
  • glossary that substitutes external links to wiki and other posts, to not interrupt your reading with terms lookup.

More information and download link is available here.

Reblog this post [with Zemanta]
PHP Profiling – XHProf

PHP Profiling – XHProf

Posted 30 December 2009 | By vinu | Categories: PHP | No Comments

binary code and magnifying glass
XHProf is a heriarcical profiler for PHP originally developed by Facebook and then opensourced. The raw data collection component is implemented in C (as a PHP extension). The reporting/UI layer is all in PHP. It is capable of reporting function-level inclusive and exclusive wall times, memory usage, CPU times and number of calls for each function. Additionally, it supports ability to compare two runs (hierarchical DIFF reports), or aggregate results from multiple runs.

Here are some of the reports that XHProf provides:

  • Flat profile (screenshot)
  • Hierarchical profile (Parent/Child View) (screenshot)
  • Diff Reports : The “flat” view (sample screenshot) & “hierarchical” (or parent/child) diff view of a function (sample screenshot).
  • Callgraph View (sample screenshot)
  • Memory Profile : XHProf’s memory profile mode helps track functions that allocate lots of memory.

If you are looking for an article which gives you details on how to install this extension in Ubuntu and a quick runthrough of how to use this, Lorenzo Alberton has an excellent article on this at Profiling with XHProf. There’s also a good background article on XHProf and why Facebook developed this extension over at Facebook.

Links:
XHProf Documentation
XHProf on PECL
Profiling with XHProf

Image Credit: from Crestock Photos

Compress your serialize output using igbinary

Compress your serialize output using igbinary

Posted 24 November 2009 | By vinu | Categories: PHP | 1 Comment

Igbinary is a  replacement for the standard PHP serializer. While the PHP serializer uses a texual format to represent the data in the serialized version, igbinary uses a binary format which is compact. This helps in brining down the storage size of the serialized data. This helps while trying to store the data in shared memory or memcache, which uses (limited) RAM to provide faster access to data.

Since I couldn’t find any pre-built binaries, I compiled the code which I got from their site. I compiled the 1.02 build.

Here are quick steps to compile this as a PHP extension for your system ( I tried this on Ubuntu, but should work on other distros as well). Uncompress the contents of the file to a directory and head over to the directory and run the following comands one after the other. Make sure there are no errors in each stage.

>phpize
>./configure CFLAGS="-O2 -g" --enable-igbinary
>make
>make install

If all goes well, the file igbinary.so should be present in your default php extension directory. Once you see this file there, head over to your php.ini file and add the following line at the end of it so that the extension is loaded with PHP.

# Load igbinary extension
extension=igbinary.so

Once you do this, restart your apache server to reload the PHP configurations. When you run phpinfo(), you should see the following lines in the output:
igbinary in phpinfo

Once you’ve got that in your output, all you need to do is to substitute serialize with igbinary_serialize and unserialize with igbinary_unserialize in your code.

To see the differences in the two formats and see if the serialized and the subsequent unserialize I use the following script with some dummy data to print out the size of the output string of serialize and igbinary_serialize.

$arrc[3]=1;
$arrc[2]=2;
$arrc[0]=3;
$arrc[1][]="Testing";
$arrc[1][]="another data";
$arrc[1][]="structure";
$arrc[]=1;
$arrc[]=2;
$arrc[]=3;
$a = serialize($arrc);
echo "<br />size of Serialize :". strlen($a);
$b = igbinary_serialize($arrc);
echo "<br />size of igbinary :". strlen($b);

The output of this script came up showing that output from igbinary_unserialize does indeed use less space than the the output of serialize. Here’s the output of this script when I ran it:

size of Serialize :126
size of igbinary :74

If you want the igbinary functions to auto replace the default serialize in the PHP session handler, all you need to do is to add the following lines in your php.ini

# Use igbinary as session serializer
session.serialize_handler=igbinary

If you have any experience in using this extension on your projects, let us know your thoughts and observations. You can get more information on igbinary from the author’s site at: http://opensource.dynamoid.com/

Simple Cloud API for Cross-Cloud Implementations

Posted 29 September 2009 | By vinu | Categories: Cloud Computing, Interoperability, PHP | No Comments

Zend has launched the Simple Cloud project which allows PHP developers to write Cloud based apps without having to bother about the different cloud based solutions available. This works like an abstraction layer for various cloud solutions like Amazon, Windows Azure, Rackspace Cloud Hosting and a few more.

Initially this project aims at providing standard cross-cloud simple APIs for

  • File storage- including Windows Azure blobs, Rackspace Cloud Files, Nirvanix Storage Delivery Network and Amazon S3
  • Document Storage- including Windows Azure tables and Amazon SimpleDB
  • Simple Queues- including Amazon SQS and Windows Azure queues

From Zend’s press release, “Zend Cloud will also provide adapters for local services to make offline coding and testing against cloud services as easy as connected development.

These APIs will be appearing soon on the Zend Framework as the Zend Cloud component. They will provide the basic functionality across the various cloud hosting services, but if you do need vendor specific functionality in your code, Zend Framework will provide vendor-specific libraries as well. They’ve already got Nirvanix, Amazon EC2, S3 and SQS covered. Microsoft’s proposed the WindowsAzure services for Zend Framework. IBM and Rackspace are also working with Zend to get their services covered. With these integrations in motion, they estimate that ZendCloud adapter with these features will be available in the Zend Framework by end of Q4.

An initial Simple Cloud API proposal and reference implementation is available now for community review and participation at http://www.simplecloud.org.

Links:

Zend Press Release – Zend Teams with IBM, Microsoft, Rackspace and Other Cloud Leaders on Open Source Initiative to Drive Cloud Application Development
MSDN Interoperability Blog – Microsoft, Zend and others announce Simple API for Cloud Application Services

Reblog this post [with Zemanta]
Fastrack with PHP on Windows

Fastrack with PHP on Windows

Posted 14 September 2009 | By vinu | Categories: Interoperability, PHP, Programming | No Comments

interopThis article is the start of a series of articles on how PHP interoperates with other technologies. When people think of PHP, the first thing people think of is LAMP. But PHP is not limited to the run just under Apache, you can have PHP run under various configurations, including the command line. Here’s the first article in this series which shows you how to get PHP working in IIS.

A few weeks back I had attended the Virtual Tech Days events, specifically the Interop sessions. I was quite interested in seeing what Microsoft had to offer for PHP developers. Going through the oveview of the programs, they seem to have come up with quite a few solutions for PHP developers. One of the important integrations for PHP is the ability to run PHP directly from IIS, as a FastCGI app, without having to install Apache in Windows. [...]

PHP worst practises

Posted 21 August 2009 | By vinu | Categories: PHP, Techniques | No Comments

PHP LogoYou’ve read a lot of PHP best practises articles and topics all over the internet and try your best at following them during your development. How about the worst practises in PHP development? There’s a nice article on the PHPDev Blog which tells you about a few practises (which I’m sure most of us haven fallen a prey to during our careers) which should be avoided at all costs.

Some of the practices include in the article are “I don’t need no documentation” syndrome and “My code is the way to go” when other better alternates are out there. Why don’t you head out and read the full article there?

PHP Worst Practices

Zend Framework 1.9.1 released

Posted 14 August 2009 | By vinu | Categories: PHP | 1 Comment

zend_framework_logoAlexander Veremyev, a Zend Framework team member has announced the latest release of the Zend Framework 1.9.1.  This is the first maintenance release in the 1.9 series and has bug fixes for  over 30 issues. You can view the full changelog for this release over at: http://framework.zend.com/changelog/1.9.1

You can download Zend Framework 1.9.1 at: http://framework.zend.com/download/latest

Are you ready for PHP 6?

Are you ready for PHP 6?

Posted 22 July 2009 | By vinu | Categories: PHP | No Comments

php6unicodeHere’s an article from Linux Magazine showing you how to install a development snapshot version of the latest PHP 6 build on your system. They also go on to give an overview on what’s new in PHP 6  and some of the code you’ll have to change in your current source to get it working on PHP 6.

The good thing about PHP 6 is that by default all strings are treated as Unicode characters, unlike the earlier versions where a lot of the default functions in PHP used to break up unicode characters and essentially junked the data. UTF-8 is now  the default encoding for many of the PHP 6 functions, so you don’t have to worry about your unicode data getting junked. In PHP 6 you have to watch out when you’re handling binary data, you’ll have to explicitly typecast your binary data or risk getting it junked because PHP 6 thinks of it as unicode :)

$binStr = (binary)$rawdata;

You can also declare the encoding of your PHP script by the following command:


Even your OO code where you were following the pre PHP 5.3 object models will not work here, since object model compatibility is removed. So your classes should be like this:

 class newClass {
   private $variable;
   public function myMethod {
    }
 }

instead of the old notation in 4.3 which used to look like this:

 class newClass {
   var $variable;
    function myMethod {
    }
 }

Read more on this topic at Linux Magazine: Get Ready for PHP 6

Image Credits: Narno via Flickr