2011年12月30日星期五

Site News: Popular Posts for the Week of 12.30.2011

Popular posts from PHPDeveloper.org for the past week:

Mark Story's Blog: New errors in PHP 5.4


In this quick new post to his blog Mark Story talks about two new errors he ran across when upgrading his installation to PHP 5.4, both showing up under E_ALL.



I've been running the PHP5.4 RC builds for the last few months, and there are some interesting changes in the upcoming PHP release. On top of all the great new features coming in PHP5.4. After updating to PHP5.4-RC4, a few things that used to not trigger errors and silently do the wrong thing, now trigger notices or warnings.


The two he mentions deal with a new warning on illegal string offsets and the other about string offsets ("Notice: String offset cast occurred"). You can find out about more changes in the PHP 5.4 series in the various Changelogs for each Release Candidate and beta release.

Community News: Conference Call for Papers Reminders!


As the conference season for next year gets closer, several conferences have opened their Call for Papers. A few of them have deadlines coming up soon, so don't forget the following important dates if you'd like to submit!




Be sure to submit while there's still time! Thanks to Thijs Feryn for the reminder!

2011年12月29日星期四

Site News: Blast from the Past - One Year Ago in PHP

Here's what was popular in the PHP community one year ago today:

Dzone.com: Open source PHP projects of 2011


On Dzone.com today Giorgio Sironi has posted what he considers to be some of the most popular Open Source PHP projects of 2011 including Symfony2, Doctrine and HipHop.



This non-scientific analysis of the popular and exciting PHP projects starts from researches on active projects on SourceForge and GitHub; the latter is where most of the collaboration and involvement of PHP developers is today. I've also crowdsourced the question on Twitter to catch projects I wasn't aware of, and I hope to do the same with you.

Other projects included in his list are:



  • Symfony2 Components
  • Moodle
  • Composer and Packagist
  • Drupal, Joomla, Wordpress


Have a project you think he missed? Let him know!

PHPMaster.com: Writing Custom Session Handlers


On PHPMaster.com today there's a new post showing you how to write custom session handlers - in their case, a database-based option that can span across multiple servers/services.



Sessions are a tool which helps the web programmer overcome the stateless nature of the internet. You can use them to build shopping carts, monitor visits to a website, and even track how a user navigates through your application. PHP's default session handling behavior can provide all you need in most cases, but there may be times when you want to expand the functionality and store session data differently. This article will show you how the default functionality works and then goes on to show you how override it to provide a custom solution.


They introduce how sessions are stored normally (based on the save path) and what the serialized contents of it would look like. They show you how to take this, normally stored on the local file system, and change it to be written to a "session" table in a MySQL database (via PDO). It includes reading, writing, updating and some garbage collection to clean out old values from the table.

2011年12月28日星期三

Community News: Latest Releases from PHPClasses.org

PHP.net: PHP 5.4.0RC4 Released!


The latest version of PHP in the 5.4.0 release candidate series has been posted - PHP 5.4.0 RC4, complete with new features and lots of bugfixes.



The PHP development team is proud to announce the 4th release candidate of PHP 5.4. PHP 5.4 includes new language features and removes several legacy (deprecated) behaviours. Windows binaries can be downloaded from the Windows QA site. THIS IS A RELEASE CANDIDATE - DO NOT USE IT IN PRODUCTION! This is the 4th release candidate. The release candidate phase is intended as a period of bug fixing prior to the stable release. No new features should be included before the final version of PHP 5.4.0.


Updates in this release candidate include an update to the max_input_vars directive and a fix for a segfault in the traits code. You can find the full notes for the release in the NEWS file and can download the latest from the PHP.net site - source downloads, Windows binaries.

Nikita Popov's Blog: Don't be STUPID: GRASP SOLID!


Nikita Popov talks about the SOLID coding practices and creates his own acronym for the complete opposite - STUPID (Singleon, Tight coupling, Untestable, Premature optimization, Indescriptive naming, Duplication).



Ever heard of SOLID code? Probably: It is a term describing a collection of design principles for "good code" that was coined by Robert C. Martin (aka "uncle bob"), our beloved evangelist of clean code. [...] So, why not approach the problem from the other side for once? Looking at what makes up bad code.


He goes through each part of his STUPID acronym and talks about how it can hurt your code and a few alternatives to help make your application more flexible and easier to maintain in the long run. He also mentions GRASP (General Responsibility Assignment Software Principles), another set of good practices to follow, some similar to SOLID, that can make your app better.

2011年12月27日星期二

Community News: Latest PECL Releases for 12.27.2011

Latest PECL Releases:

Henrik Bjørnskov' Blog: Symfony2: Quick tip for your security configuration


Henrik Bjørnskov has a quick new post with a security tip for those using the Symfony2 framework in its configuration.



Earlier when playing around with the Security component and SecurityBundle i found that for all paths you can specify a route name and the component will match it when check for the request paths.


Setting this up in your configuration gives you more control over the paths that are matched as well as more flexibility in defining them. He includes a note about a change you might have to make to the SecurityBundle's code to get the "check_path" part working correctly. You can find out more about the SecurityBundle's integration in this blog post from Pablo Bandin.

Joe Devon's Blog: Belated Zendcon 2011 Recap


On his "MySQL Talk" blog Joe Devon has posted a (very) belated wrapup of ZendCon 2011 he attended earlier this year.



I started writing a Zendcon recap post as soon as I got back. And then mis-timed a couple projects. Note to freelancers, make sure your new gig starts AFTER your old gig is over. Or you'll be working an insane schedule. Hence the lateness... First the good part. What made Zendcon special.


He notes that it was a great opportunity to meet people "in real life" that he'd only spoken with online and the overall wonderful experience it was. He mentions some specific people in the PHP community including Juozas Kaziukenas, Daniel Cousineau, some impromptu singing of Queen songs and many more (too many to name here). He also mentions some of the sessions attended including the tutorial on Zend Framework and an uncon talk from Ilia Alshanetsky about optimization.

2011年12月23日星期五

Site News: Popular Posts for the Week of 12.23.2011

Popular posts from PHPDeveloper.org for the past week:

Joshua Thijssen's Blog: php 5.4 + htrouter: Your personal Apache 2.2 compatible server


Joshua Thijssen has a new post to his blog today about a feature of the upcoming PHP 5.4 release, the built-in web server, and a handy way to reproduce .htaccess functionality with the help of a simple PHP script - htrouter.



The problem with the new PHP 5.4 internal web-server is that it isn't Apache. Thus it does not know anything about .htaccess. Even when you have defined your .htaccess to do authentication, the internal PHP web-server will ignore it, while in production, the authentication will be needed (if you will be running Apache, of course). Also, you need to reroute everything manually through your app_dev.php, so your URL's don't really match the way they will be on your production.


He introduces the PHP web server quickly, just showing a sample command line call to start it up and to point it at a certain PHP file as a "boostrap". With the help of his htrouter script, though, you can use "modules" similar to those in Apache. He already has the HTTP auth stuff working and more is to come.

DZone.com: Social Comparison of PHP Frameworks


In this post to DZone.com today, John Esposito points out a site that compares popular PHP frameworks socially, a collaborative resource to keep track of things like framework features, popularity and their last update.



There's this wiki-ish comparison of PHP frameworks from socialcompare.com -- presently incomplete, but already containing quite a few frameworks and interesting details of each. You can add comparison criteria (rows; folksonomically) or update existing criteria -- which currently include, among other details, ORM specifics, cache storage, template system, and testing libraries.


Frameworks currently covered include Zend Framework, CakePHP, Fat-Free, Symfony, Yii and Kohana. As it stands now, Yii is the most popular framework with 8 votes and Symfony and Zend Framework are tied for second with 5 points each.

2011年12月22日星期四

Site News: Blast from the Past - One Year Ago in PHP

Here's what was popular in the PHP community one year ago today:

Community News: Dutch PHP Conference 2012 Announced (and Call for Papers Opened)


The Dutch PHP Conference has Call for Papers has also been opened!



We're back! And we are glad to announce that we'll be organising another edition of the Dutch PHP Conference, which will be held in Amsterdam from 7th to 9th June 2012. Thursday 7th will be the tutorial day and June 8th and 9th will be the main conference days. Ticket sales will start on February 15th. [...] We're looking for high-quality, technical sessions from speakers who can cover advanced topics and keep our demanding audience inspired


The Call for Papers is open until January 31st, so get those talk ideas in soon. In addition to the normal DPC conference, they're also holding the Dutch Mobile Conference at the same time, a 3-day conference about technologies used for mobile websites and mobile web application development.

Mike Willbanks' Blog: RPM Packaging - Building and Deploying your own PHP


Mike Willbanks has a new post to his blog about a different sort of technique for deploying PHP - building your own RPMs instead of just using the pre-packaged ones. This opens up a whole world of customization options.



In the PHP world, one might ask why not just build it from source? Well, an RPM IS built from source and then distributed to many servers - we can ensure that we have the same packages on each, we can maintain the same versions and if you've read my previous post on Pirum you will know that I also like mirroring PEAR packages.


He walks you through the structure of an RPM package (the spec file, with examples, and the source), the "%prep", "%build" and "%install" containers as well as where the source needs to live for things to work correctly.

2011年12月21日星期三

Community News: Latest Releases from PHPClasses.org

Phil Sturgeon's Blog: PHP Basher Bashing


In a new post to his blog today Phil Sturgeon responds to some comments made in another post about PHP not "being an acceptable COBOL".



Anyone who has used PHP for a while knows that it has its ugly parts. Recently I've seen a whole swathe of PHP-bashing articles and that would fine if they were they are making a valid point, but some of it has just been - as I tweeted recently - "absolute drivel".


He directly refutes some of the points made in that article, points out a newer post from the same author (which misses some points as well) and finishes it off with a look at why he "still" uses PHP versus something like Closure or NodeJS for his development.



Despite known flaws and imperfections I continue to use PHP as my primary language because during all the time I spend worrying about which technology is the neatest, coolest or shiniest I could have built a new application to sell or finished another client site.


Be sure to check out the comments for some other thoughts about the language (and Phil's responses).

php|architect: A Chat on Zend's phpcloud at ZendCon 2011


On the php|architect site today Keith Casey has posted a recording of an interview with Boaz Ziniman of Zend about one of their latest offerings, phpcloud - a platform-as-a-service to provide easy, scalable PHP application hosting.



At the tail end of ZendCon 2011 in October, I managed to corner Boaz Ziniman to chat on the launch of their new product phpcloud. We covered features, limitations, design & implementation considerations, and how it's different than most of the other options out there.


If you'd like to listen, you can grab the mp3 here. It's about 15 minutes long. You can find out more about Zend's cloud offering on phpcloud.com.

2011年12月20日星期二

Community News: Latest PECL Releases for 12.20.2011

Latest PECL Releases:

PHPMaster.com: PHP's Quest for Performance: From C to hhvm


On PHPMaster.com today there's a new post from Matthew Turland talking about PHP's quest for performance and some of the recent advancements that have made better performing applications even more possible.



While it's sufficient for many users, as PHP sees increased use by large sites like Wikipedia and Facebook, the ability to serve more requests on fewer servers becomes increasingly important. Some efforts have been made in this area in the last few years, both within and outside the PHP internals team. However, understanding exactly what's going on requires a bit of background both in history and concepts.


He goes through some of the origins of the PHP language (from the early days with Rasmus Lerdorf) to the fact that the PHP language itself is interpreted - complete with some of the overhead that comes with that. He also mentions various projects that have tried to compile PHP back down to C to increase performance like Roadsend, HipHop and, most recently, the HipHop virtual machine from Facebook.

Oliver John Tibi's Blog: Mobile-ize Your CakePHP Application


In a new post to his blog, Oliver John Tibi has the first part of a series looking at mobile-izing your CakePHP application, making it mobile friendly when a mobile browser is detected.



I'll be writing a short series of posts on how to create a mobile version of your CakePHP app. I've always been bragging to my peers how awesome CakePHP is, and so now I'm writing a short tutorial on how to create a mobile-friendly version of a CakePHP app. I promise to make this as easy as possible.


In this first part of the series he helps you do two things - set up some custom routes for the mobile version of the site ("/m") and add in browser detection using the RequestHandler's "isMobile()" method.

2011年12月19日星期一

Community News: Latest PEAR Releases for 12.19.2011

Latest PEAR Releases:

Michaelangelo van Dam' Blog: Configuring Zend Framework apps for Windows Azure


Michelangelo van Dam is back with the second part of his series looking at running PHP applications on Azure (the first part is here). In this new post he focuses more on configuring and building an actual application, one based on the Zend Framework.



Building web applications is nothing new anymore, as we've been doing it since the early days of the internet, but we've always done this on a single system. Even when Zend Framework came round, we kept doing the same thing and build apps for a single environment.
But as I've discussed already in my previous article, developing for the cloud requires another approach. [...] With Zend Framework developing applications running on these separate compontents becomes really easy. It's like having your cloud toolbox right in your pocket.


He walks you through the settings needed to interact with a MySQL database backend, setting up sessions to write to the database, caching information to a memcache server and storing files on a remote destination (in this case cloud storage).

Robert Basic's Blog: Communicating with Pidgin from PHP via D-Bus


Robert Basic has put together a new tutorial on his blog showing how he connected PHP and Pidgin (the popular chat client) with the help of the DBus extension.



Earlier this week I got an idea of trying to communicate with Pidgin, a chat client, via the terminal. [...] Surely I wasn't the first one to come up with this idea and after a bit of a googling found out that Pidgin's libpurple has a nice API for that, exposed via D-Bus. I first planned to write some scripts for this in Python or C, but when I finally sat down over the weekend to hack on this, realized there is a PHP D-Bus extension, thanks to Derick Rethans!


He goes through the whole process you'll need to get it up and working on your system - installing the extension via PECL, creating a DBus proxy to the Pigdin interface and getting a list of the currently connected users. You can find the first versions of this code in his account on github.

2011年12月16日星期五

Site News: Popular Posts for the Week of 12.16.2011

Popular posts from PHPDeveloper.org for the past week:

php|architect: CodeWorks East 2011 Recap


On the php|architect site today Keith Casey has written up a summary of the eastern leg of the CodeWorks conference tour that just wrapped up in Orlando, Florida.



While it will still be a few days weeks until I'm finally recovered, I wanted to share a recap of CodeWorks East 2011 while it was still fresh. If you're looking for the core presenters' slides, attendees will receive them via email but they will not be published publicly until after the West Coast Tour is complete in January 2012.


He mentions their sponsor first (Adobe) and then gets into the details of each stop along their way - Madison, Nashville, Baltimore, Raleigh and finally Orlando. Their west coast tour kicks off on January 10th in Seattle (with further stops in Portland, San Francisco, Los Angeles and Austin). You can find out more about the event on the CodeWorks site.

Sebastian Bergmann's Blog: Using CLANG/scan-build for Static Analysis of the PHP Interpreter


In a new post to his blog Sebastian Bergmann takes a quick look at using a static analyzer, clang and scan-build, to analyze the PHP interpreter (specifically during the compile process).



I have been tinkering with CLANG's static analyzer lately. This post summarizes how I installed LLVM and CLANG and performed the analysis of a build of the PHP interpreter.


He includes all the commands (unix-based) to get the clang tools/libraries installed in the correct places as well as what to add to your $PATH to get the "scan-build" command to work with the make and make install parts of the PHP compile process.

2011年12月15日星期四

Site News: Blast from the Past - One Year Ago in PHP

Here's what was popular in the PHP community one year ago today:

Lineke Kerckhoffs-Willems' Blog: ProTalk update December 2011


Lineke Kerckhoffs-Willems has a new post to her blog today with an update about their in-progress site that wants to share tech knowledge through video, ProTalk:



A lot has happened since my October post announcing ProTalk, the secret project I am working on with my friend, Kim Rowan. So much in fact that now seems the ideal time to update you on our progress! Now, down to business! Since announcing the project in early October we have achieved the [several] project milestones.


The milestones include hosting by Combell (who also host Joind.in), a new domain, a commitment from Ibuildings for a design/logo/wireframe set and a new twitter account.



ProTalk is a "community resource aiming to provide a central point of access to video and audio content with a PHP focus." For more information and to sign up for details when they launch, check out their new site.

PHPClasses.org: Can .NET make PHP run faster than the official PHP implementation?


On the PHPClasses blog today the question is posed "can .NET make PHP run faster than the official PHP implementation?" (relating to the use of the Phalanger tool to compile PHP down to .NET assemblies.



Recently Phalanger 3.0 was released introducing numerous improvements in terms of compatibility with the PHP 5.3, interoperability with .NET platform implementations including Mono on Linux, and probably most importantly performance improvements. [...] What motivated this article was that a PHP developer named Rasmus Schultz went on the php.internals mailing list and proposed to switch the official PHP implementation based on Zend for another based on Phalanger.


The post includes some benchmarking results of requests made to a WordPress instance running on various PHP platforms. The Phalanger version came in around 2 seconds faster (average, obviously) than the PHP FastCGI setup. Also included are two suggestions for future PHP versions (v6 anyone?) that could help the language perform even better: Thread-safety for running with less memory waste and the inclusion of a JIT (Just in time compiler - of which a few are mentioned specifically.

2011年12月14日星期三

Community News: Latest Releases from PHPClasses.org

Community News: CICONF '12 Speaker List


The CICONF (CodeIgniter conference) group has made a new post about the lineup for their next event including people like Adam Griffiths, Alex Bilbie, Alexis Serneels, Harrow "WanWizard" Verton, Nick Jackson and Tyler Flint.



The chances are if you are using a library, addon, Spark or tutorial for your CodeIgniter projects it will have been written by one of these guys. Adam Griffiths wrote the book, Alex Bilbie has made some amazing OAuth 2 and Mongo code, WanWizard wrote DataMapper ORM - the most popular ORM used with CodeIgniter - and I've [Phil Sturgeon] released a few blogs about CI over the years.


They'll be doing the double-event conferences this year again - this time they'll be in London (February 18th-19th and San Francisco at a yet to be determined date). If you'd like to attend the London sessions, you can already purchase your tickets - a student pass for £35 and a standard ticket for £45.

Chris Hartjes' Blog: Better HTTP Request/Response in PHP


In a recent post to his blog Chris Hartjes looks at the idea of better HTTP Request/Response functionality in PHP, more than just the superglobal handling and PECL HTTP extension it has now.



I think the fact that we have $_POST and $_GET lulls some of us into the false sense that we should have $_PUT and $_DELETE objects, since that would map to the commonly-desired set of HTTP verbs that REST likes to use. But what should be inside those things, or should we be moving towards a more Pythonesque solution where a Request object, as part of core or via a only-really-for-the-brave- PECL extension?


He mentions opinions from other PHP community members (Laura Thompson and Elizabeth Smith) and a bit about what he (and I'm sure other developers) are looking for in a more full-featured request/response handling feature.

2011年12月13日星期二

Community News: Latest PECL Releases for 12.13.2011

Latest PECL Releases:

Bradley Holt's Blog: Boston PHP Northeast Conference


Bradley Holt has a new post to his blog announcing the Boston PHP Northwest Conference happening in August (2012) in Cambridge, Massachusetts:



I'm excited to be able to announce that the first ever Boston PHP Northeast Conference will be taking place on Saturday, August 11th and Sunday, August 12th at Microsoft's NERD Center in Cambridge, MA. This regional event is intended for PHP beginners, enthusiasts, and professionals alike.


The conference will not just cover PHP but also general web development topics with a dash of user experience thrown in. Three regional groups are hosting the event: BostonPHP, Burlington, VT user group and the Atlantic Canadian PHP user group.

ZendCasts.com: RESTful Delete with SLIM, jQuery and JSON


Continuing on with his webcast series looking at using the Slim microframework to create a RESTful web service with JSON Output, John Lebensold takes the code from the previous tutorials (part one, two, three) and adds handling for DELETE to remove values from the data.



This tutorial will show you how to add jQuery RESTful calls for using the DELETE verb when deleting items via a JSON REST interface.


You'll definitely need to check out either the previous tutorials in the series to follow along with the code or grab the current source to see how everything's structured.

2011年12月12日星期一

Community News: Latest PEAR Releases for 12.12.2011

Latest PEAR Releases:

Andrew Johnstone's Blog: Vagrant, Automating PHP/MySQL Installation with bash/slack


Andrew Johnstone has a new post to his blog with a look at using Vagrant for continuous deployment of a PHP-based application.



Vagrant is simply a wrapper around Virtualbox headless that allows for provisioning virtual machines with support for puppet, chef-solo, chef, and bash. This allows you to automate the deployment and sandboxing of development sites. Additional base box images can be found at vagrantbox.es.


He walks you through the full process of setting up a first deployment - getting Vagrant installed, updating the config for a squeeze64.box image, configuring a virtualhost on the Apache web server and setting up a "preinstall" script to configure things like MySQL and install a long list of packages (via apt-get).

Michaelangelo van Dam' Blog: Windows Azure for PHP developers


In a new post to his blog, Michelangelo van Dam starts off a series looking at Windows Azure for PHP developer, an introduction to the service and what sorts of features it has to offer.



I'm a developer and I don't want to fiddle with setting up and maintaining an operating system, basically since I don't have the time for it. [...] I was completely sold when Josh Holmes came to Brussels in 2009 and told us more about what Windows Azure has to offer and how perfectly it is to build applications consuming these cloud services, without having to deal with setting up and maintaining the platform the run on.


He points out just a few of the features of an Azure instance - pre-installed OS (similar to Windows 2008 Server + IIS7), the five types of storage available (including Queue, SQL Azure and Blob storage). He also mentions working with file uploads, sessions, caching, database interaction and a brief comparison of cloud versus non-cloud scaling methods. In the next part of his series, he'll get more practical and show how to set up a Zend Framework application on an Azure instance.

2011年12月9日星期五

Site News: Popular Posts for the Week of 12.09.2011

Popular posts from PHPDeveloper.org for the past week:

Josh Adell's Blog: Codeworks '11 Raleigh Rundown


Josh Adell recently attended to Raleigh, North Carolina arm of the CodeWorks conference and has posted about some of his experience there (and specifics on each presentation).



I had a great time at CodeWorks 2011 in Raleigh this week, put on by the great folks at php|architect. Here is a rundown of the presentations, with some of my thoughts. [...] To all the conference speakers, organizers and attendees, I want to say thank you for a fun and educational experience.

The sessions for this stop on the tour were:



  • "CI:IRL" by Beth Tucker Long
  • "How Beer Made Me a Better Developer" by Jason Austin
  • "What's new in PHP 5.4" by Cal Evans
  • "Refactoring and Other Small Animals" by Marco Tabini
  • "jQuery Mobile and Phonegap" by Terry Ryan
  • "REST Best Practices" by Keith Casey

VG Tech Blog: Mocking the File System Using PHPUnit and vfsStream


On the VG Tech blog today there's another post related to unit testing (here's one from before) but this time they're talking about mocking the filesystem with vfsStream, a powerful tool that lets you interact with PHP streams as a virtual file system.



This article is about how to mock the file system when writing unit tests, and it will be rather code-heavy. [...] PHPUnit is the de-facto standard for unit testing in PHP projects, and this is what we will be using together with vfsStream in this article.


The include the code for a simple storage driver (VGF_Storage_Driver_Filesystem) to use with vfsStream with "store", "delete" and "get" methods. Also included are examples of using vfsStream to check things like directory existence, if a file exists, or if a file can be read. A few simple assertions are set up in their sample test to check the methods in their "VGF_Storage_Driver_Filesystem" class.

2011年12月8日星期四

Site News: Blast from the Past - One Year Ago in PHP

Here's what was popular in the PHP community one year ago today:

Volker Dusch's Blog: Book Review: PHP Masters


Volker Dusch has posted his review of a recent release from SitePoint Press - "PHP Masters - Write Cutting Edge Code".



The book is solid, well written and covers the most important topics that people need to think about when starting off with PHP. It is one of the few PHP book on the market that you can pass on to your trainees/junior developers without having to "unteach" them half of the taught bad practices afterwards. This is a great achievement in my mind and I'd definitely recommend checking it out and passing it on to your trainees and 'junior developers' ... maybe read it first yourself and rip out a few pages in chapter 4.


His "long version" gets into a more complete list of his thoughts on each of the individual chapters (including "object oriented programming", "APIs", "design patterns" and "security"). Overall, he found the book good, but pointed out a few areas where it was lacking. You can find more detail about the book here (or on Amazon here)

VG Tech Blog: Unit Testing with Streams in PHP


On the VG Tech blog today there's a new post from André Roaldseth about using PHPUnit to test PHP streams, basing the assertions on the data rather than the functionality itself.



Using the memory/temporary stream provided by php:// stream wrapper you can create a stream with read and write access directly to RAM or to a temporary file [using "php://memory"]. This gives you the possibilty to write unit tests that does not rely on a specific file, resource or stream, but rather on data provided by the test itself.


There's no specific code examples here, but you can refer to the stream wrappers section of the PHP manual for more details on this and other handy built-in streams. Once created, it can then be used just as any other stream resource can. This could be useful to provide mocks in your testing, replacing any other stream-able resource with a "memory" or "temp" placeholder.

2011年12月7日星期三

Community News: Latest Releases from PHPClasses.org

Community News: PHPFog Gifts Free-for-Life Applications


PHPFog, the PHP-centric platform as a service has made a new post to this blog about two new "gifts" they're providing to developers:



I want to thank you for your interest in PHP Fog. Thanks to you and tens of thousands of developers like you, we have grown massively in the last year and a half. As a sign of my gratitude, I'd like to give you two free gifts.


Their gifts to the community are a conversion of the 6 month applications over to a free-for-life product and you can now deploy three of these "free forever" applications instead of just the one. You can signup here for the service with offerings of installed software like PyroCMS, Drupal 7, MediaWiki and Slim. For more information, you can attend this webinar.

Mrinmoy Ghoshal's Blog: Concept of Strings:PHP


If you're new to the PHP language and are looking for the full scoop on working with the string datatype, look no further than this new post from Mrinmoy Ghoshal. It's an excellent (and quite complete) resource for just about everything involving strings in PHP.



A string is series of characters, where a character is the same as a byte. This means that PHP only supports a 256-character set, and hence does not offer native Unicode support. See details of the string type.


The tutorial is broken up into different sections for easier consumption:



  • Single quoted
  • Double quoted
  • Heredoc
  • Nowdoc
  • Variable parsing
  • String access and modification by character
  • Useful functions and operators
  • Converting to string
  • String conversion to numbers
  • Details of the String Type

2011年12月6日星期二

Community News: Latest PECL Releases for 12.06.2011

Latest PECL Releases:

Joshua Thijssen's Blog: SPL: Using the iteratorAggregate interface


Joshua Thijssen has a recent post spotlighting a part of the Standard PHP Library (SPL) that implements that Traversable interface, the IteratorAggregate interface.



Together with its more famous brother "Iterator", they are currently the two only implementations of the "Traversable" interface, which is needed for objects so they can be used within a standard foreach() loop. But why and when should we use the iteratorAggregate?


He answers his question with an example - a book that contains chapters. With a normal iterator you'd have to define standard functions (like valid, rewind or key). Using the IteratorAggregate you can push items into an internal array (like chapters in a book) and call a "getIterator" method to get this set. He also takes it one step further and shows implementing the "Count" interface to make it easier to get a total count of the items in the iterator. Sample code is included to help clarify.

DZone.com: Codeigniter and Object-Oriented PHP: Two Guides


On DZone.com today John Esposito points out two CodeIgniter tutorials that can help you on your way to becoming a pro with this popular PHP framework.



As Codeigniter builds on its (already considerable) popularity, now might be a good time to think about using the massively community-supported PHP framework to its maximum potential, if you aren't already. Here are two tutorials to check out, depending on your level of familiarity with object-oriented PHP and frameworks.

Here's the two he mentions:




The second tutorial is a little older, but the functionality of the framework hasn't changed dramatically since then so most of it should still apply.

2011年12月5日星期一

Community News: Latest PEAR Releases for 12.05.2011

Latest PEAR Releases:

PHPMaster.com: Charting with pChart


On PHPMaster.com today there's a new post highlighting the use of pChart to graph out the data from your PHP application. pChart provides an easy interface to draw graphs with GD, supporting alpha transparency, shadowing, spline/cubic curves and much more.



Created and maintained by Jean-Damien Pogolotti, a systems engineer based in Toulouse, France, pChart is a library that creates anti-aliased charts and graphs using PHP. It's object-oriented code has been recently redesigned and makes it easy to add beautiful, eye-catching data. The library is free for non-profit use and for inclusion in GPL distributed software; licensing plans for other uses start at just 50 Euro. In this article I'll take you through installing pChart and using it to generate a basic chart, line chart and plot graph.


He walks you through the download and installation of the tool as well as showing the code you'll need to include to get started with a first script. Their examples show how to create both single- and three-series charts with some sample data and some screenshots of output.

WebDevRadio: Episode 94: Keith Casey Interview from Zendcon 2011


On the WebDevRadio podcast, Michael Kimsal has posted an interview with Keith Casey from this year's ZendCon 2011 conference.



I got a chance to sit down with (the legend) Keith Casey. Keith's well known in the PHP community with his web2project project (among other things) and is now poised to be a greater force in the worlds of Twilio and the Austin tech scene. Volume is a little quiet here, so turn it up to hear Keith's words of wisdom.


You can listen to the episode either via the in-page player or by downloading the mp3 directly to listen at your leisure.

2011年12月2日星期五

Site News: Popular Posts for the Week of 12.02.2011

Popular posts from PHPDeveloper.org for the past week:

Jake Smith's Blog: Callback Filter Iterator in PHP 5.3/5.4


Jake Smith has a new post to his blog today about a feature included in PHP's Standard PHP Library that you might have overlooked - the FilterIterator's callback functionality.



The Filter Iterator is probably my second favorite iterator, next to Directory Iterator. There are many great use cases for the Filter Iterator, and when you do filter the original data is left untouched. A Filter Iterator is really simple to use, create a class that extends FilterIterator and adjust the accept method to meet your criteria. This is great and all, but having the ability to create filter iterators on the fly, ones that won't be used application wide, without having to create a class is even better.


He includes a bit of code defining a FilterCallbackIterator class with a "callback" parameter passed into the constructor (in his case, a closure). Also included is some sample code of it in use - handling an array (well, ArrayIterator) with a simple true/false check on the current array value. You can find out more about this functionality in the PHP manual.

Joshua Thijssen's Blog: Compatible code: starting with symfony2


In a new post to his blog, Joshua Thijssen documents some of his first steps into the world of the Symfony2 framework (as a developer who has lived mostly in a Zend Framework/CodeIgniter world). His post doesn't compare the frameworks, it's just his discovery along the way.



A friend of mine who is a big supporter of Symfony told me to give Symfony1 a shot. Off course I was skeptical since I knew less about symfony1 than I did on Zend_Tool. That, plus the fact we needed to autoload, bootstrap and get two frameworks up and running simultaneously. What could possibly go wrong! Conclusion: I've got my tool up and running about a 45 minutes later...


He talks about the process he went through to download, setup and configure the framework and start using a "task" to create a simple executable script. He also briefly compares Symfony1 to Symfony2, noting that SF2 is a bit more "out-out-of-the-box friendly" than SF1. The overall experience was a positive one, though. You can find out more about Symfony1 here and Symfony2 here.

2011年12月1日星期四

Site News: Blast from the Past - One Year Ago in PHP

Here's what was popular in the PHP community one year ago today:

PHPMaster.com: Defining and Using Functions in PHP


PHPMaster.com has a new article for those new to the PHP language posted this morning - an introduction to using functions and making your code more reusable.



Let's start by defining the word "function." A function is a self-contained piece of code which carries out a particular task (or function!). A key benefit of using functions is that they are reusable; if you have a task that needs to be performed a number of times, a function is an ideal solution. They can be either defined by you or by PHP (PHP has a rich collection of built-in functions). This article will focus on programmer-defined functions but will touch briefly on PHP's functions to complete the picture.


They include a few code snippets showing the syntax of functions (including their name, arguments and returning a value). They suggest grouping your functions together in your code for easier maintenance and share a handy tip on making a function accept a varying number of arguments.

2011年11月30日星期三

Community News: Latest Releases from PHPClasses.org

PHP.net: PHP 5.4 RC2 released


The PHP.net site has officially announced the availability of the latest Release Candidate for the PHP 5.4.x series - PHP 5.4 RC2:



The PHP development team is proud to announce the second release candidate of PHP 5.4. PHP 5.4 includes new language features and removes several legacy (deprecated) behaviours. Windows binaries can be downloaded from the Windows QA site. THIS IS A RELEASE CANDIDATE - DO NOT USE IT IN PRODUCTION!. This is the second release candidate. The release candidate phase is intended as a period of bug fixing prior to the stable release. No new features should be included before the final version of PHP 5.4.0.


Fixes in this new version include updates to the built-in web server, PHP-FPM no longer being marked as experimental and changes to the Zend Engine, Core and various extensions. See the NEWS file for complete details. You can download this latest release from the downloads page (and here for Windows users).

Community News: Zagreb PHP User Group December 2011 Meeting - 13th @ 6pm


Miro has submitted some information about the latest meeting of the Zagreb PHP User Group happening December 13th at 6pm in the Multimedia Institute:




Although Zagreb PHP Meetup started only 3 months ago with monthly meetups (up to 30 developers coming), our next meeting will be first meetup with organized talks. December meetup will have 5 talks with themes like 'How to write readable code?', 'Flex & PHP development' , 'Introduction to test driven development' && 'MySQL - explain explained'.



We would like to invite all interested PHP and non-PHP developers that would like to listen to some of best Croatian PHP devs (and understand Croatian language) to come on December 13th from 6PM to Mama, Preradoviceva 18 in Zagreb. Unfortunately we are limited with number of available seats so please signup at http://zgphp.eventbrite.com/.




Due to space limitations, there's only 12 seats available so hurry and reserve your spot if you'd like to attend (it's free)!



Have a user group meeting you'd like announced? Let us know!

2011年11月29日星期二

Community News: Latest PECL Releases for 11.29.2011

Latest PECL Releases:

Brian Swan's Blog: The SQL Server ODBC Driver for Linux is Available!


As Brian Swan has mentioned in his latest blog post, the ODBC database driver for SQL Server on Linux has been released. This is a huge step forward for directly connecting linux-based systems (and programming languages) to this popular Microsoft product.



The first beta release of the SQL Server ODBC Driver for Linux is available for download! As announced in October, the "Multiplatform Team" (a.k.a. the "MPlat Team") has released a preview version of a driver that will provide first-class access to SQL Server from applications running on Linux operating systems. The team is looking for feedback on this release to incorporate into their production-ready release, so try it out and let us know what you think.


He links to a few resources about the release - more details, a link to download the driver and the official documentation.

PHPMaster.com: Introduction to Git, Part 1


If you haven't gotten a chance to try out git for your version control system, now's the perfect time. PHPMaster has an introduction to using git for a simple PHP project. It introduces you to some of the basics and gets you up to speed quickly.



Some of the more commonly used version control systems that you have likely heard about are CVS and Subversion. This tutorial will take a "forget everything you know about CVS or Subversion" approach. As someone who has used all three of these systems in the professional realm, I can testify that some knowledge of CVS or Subversion can be useful when approaching Git, but it is not necessary. The best way to learn Git is to start using Git for what Git is.


They break it up into a few different sections - why use git, how to create a new repository, adding/staging files for commit, viewing the project history and viewing diffs for different versions. This is the first part in a series, so keep tuned for future parts touching on branching, merging and working with remote repositories.

2011年11月28日星期一

Gonzalo Ayuso's Blog: Playing with the new PHP5.4 features


Gonzalo Ayuso has a new post to his blog today showing some of the experimentation he's done with PHP 5.4 features like the short array syntax, calling methods through arrays and traits.



PHP5.4 it's close and it's time to start playing with the new cool features. I've created a new Virtual Machine to play with the new features available within PHP5.4. I wrote a post with the most exciting features (at least for me) when I saw the feature list in the alpha version. Now the Release Candidate is with us, so it's the time of start playing with them. I also discover really cool features that I pass over in my first review.

Code snippets are included for each example for:



  • Class member access on instantiation
  • Short array syntax
  • Support for Class::{expr}() syntax
  • Indirect method call through array
  • Callable typehint
  • Traits
  • Array dereferencing support


He points to this other post for a complete list of what's been added in 5.4.

2011年11月24日星期四

Engine Yard: The Future of PHP: PEAR and Pyrus Webcast Recording


If you missed out on the Future of PEAR/Pyrus webcast event put on by Engine Yard, you're in luck - they've posted a recording of the event.



In this panel discussion, we tackle topics including the direction PEAR and Pyrus will be going in the next few years, obstacles that may be on the horizon, and more.


PEAR is the package library of standardized packages for a variety of common development tasks. Pyrus is a new package manager to make installing and maintaining PEAR packages simpler. Engine Yard's next webcast will cover the Lithium framework with core contributors Nate Abele, Garrett Woodworth, and John Anderson on December 1st.

Site News: Blast from the Past - One Year Ago in PHP

Here's what was popular in the PHP community one year ago today:

2011年11月23日星期三

Lorna Mitchell's Blog: POSTing JSON Data With PHP cURL


On her blog today Lorna Mitchell has a quick tip for anyone having an issue sending POSTed JSON data with the curl functionality that can be built into PHP. The trick to her method is sending things with the right header.



We can't send post fields, because we want to send JSON, not pretend to be a form (the merits of an API which accepts POST requests with data in form-format is an interesting debate). Instead, we create the correct JSON data, set that as the body of the POST request, and also set the headers correctly so that the server that receives this request will understand what we sent.


She includes a code example (about ten lines) showing the POSTing process that sets up options using curl's curl_setopt. Be sure to set up the headers to send as "application/json" - that's the trick to letting the remote end know the format.

Community News: Latest Releases from PHPClasses.org

2011年11月18日星期五

Site News: Popular Posts for the Week of 11.18.2011

Popular posts from PHPDeveloper.org for the past week:

DZone.com: Creating a virtual server with Vagrant: a practical walkthrough


On DZone.com there's a new post from Giorgio Sironi looking at how to automate a build of a virtual server with Vagrant, setting up a LAMP-based development instance.



Vagrant ia a tool for building virtual machines (in VirtualBox's format) that conforms to a specification. It's written in Ruby, but it makes really no assumptions over the environments that you're gonna build; in this article, we will setup a virtual server for PHP applications running inside Apache.


The end result is a virtual machine based on VirtualBox images and can be built in a few easy steps:



  • install the vagrant gems on the build system
  • add a new virtual box instance pointed to a .box file
  • create the Vagrant config (including the commands to run post-create)
  • set up a little port forawrding
  • creating a phpinfo file and starting up Apache


One suggested place for grabbing images (some with pre-defined software) is Bitnami's "Stacks" repository.

DevShed: Building an ORM in PHP


On DevShed today there's a new tutorial showing you how to build a basic ORM layer on top of a MySQL database. It includes all the code you'll need (cut&paste-able, not as a download).



Obviously, with so many ORMs at one's disposal for free, it seems pretty pointless to develop a custom one; are we trying to reinvent the wheel? No, of course not. But if you need to create a simple application that performs a few CRUD operations on some related domain objects and don't want to climb the learning curve of a third-party library, then implementing a custom ORM might make sense. There's alos the educational aspect of the process (yes, learning one or two things never hurts).


They start you off with the creation of the "data persistence layer" (an interface first) to connect to the database, building a MySQL-specific one on top of it. Next up is the data mapper layer making things like "fetch by ID" and the insert/update/delete possible. Their simple example doesn't include anything about ORM relationships, though - just fetching simple rows.

2011年11月17日星期四

Site News: Blast from the Past - One Year Ago in PHP

Here's what was popular in the PHP community one year ago today:

SitePoint.com: Software Development? We're Doing it Wrong.


On SitePoint today there's a new post from Eran Galperin (of Binpress) about how, if you're jumping immediately to custom software development, you're probably doing it wrong.



Code reuse is largely accepted as "best practice" in our industry. Code reuse has many advantages, such as a smaller code-base which is easier to grok for developers. It's easier to maintain and optimize, since you can make less changes in order to achieve the desired results. Many modern techniques and tools were created in order to better reuse and modularize code. But while we're reusing code, we're duplicating effort. The same code is being written over and over in different places, wasting time and money.


He suggests that custom development should always be a last resort for software development, that there's plenty of other (open source) software out there that meets many of the needs businesses have. In his opinion, component-based development is the future of the industry - pieces that fit together with common interfaces and are larger than the sum of their parts. He sees a "commercial open source" model emerging from the current state of things. This model could result in more well maintained OS projects and more functionality being released as a part of it.



What we have currently is increasing noise, as more and more people have easier access to start programming and publishing their projects. We need to streamline the process and add that missing financial element that makes it sustainable and repeatable.

Symfony Blog: SensioLabs Connect, a week later


On the Symfony Blog today they have an update on their latest community offering, SensioLabs Connect, a service connecting Symfony developers all around the world. It's been one week since the release and there's already some changes happening.



To celebrate our 1000th user on SensioLabs Connect in a week, we have just rolled out a new version that takes into account some of the feedback we had from the community after the launch.


Changes include updates to use Gravatar images if you choose not to upload a photo, fixes for a bug with email confirmations and a few new badges added to the system - "first 100 users", "attendees of SymfonyLive" and ones based on seniority in the community. A public API is in the works, but you can grab a profile in json by adding ".json" to the end of a profile URL (like Fabien's).