2013年3月31日星期日

Community News: Packagist Latest Releases for 03.31.2013

Recent releases from the Packagist:

2013年3月30日星期六

Community News: Packagist Latest Releases for 03.30.2013

Recent releases from the Packagist:

2013年3月29日星期五

PHP.net: PHP 5.5 beta2 released


The PHP.net site has announced the release of the latest beta for the PHP 5.5 series - PHP 5.5 beta2:



The PHP development team announces the release of the second beta of PHP 5.5.0. This release fixes some bugs from beta one that could prevent the release from compiling. [...] Our next beta is expected for April 11th.


This is a development preview, so do not use it in production. Several bugs were fixed in this beta release - you can view the NEWS file for a complete list. If you'd like to help test it out in your environment and with your applications, go download it (Winodws) and give it a shot. You can provide issues you might find back to the bug tracker.

Site News: Popular Posts for the Week of 03.29.2013

Popular posts from PHPDeveloper.org for the past week:

Community News: Packagist Latest Releases for 03.29.2013

Recent releases from the Packagist:

Larry Garfield: On empty return values


Larry Garfield has posted some of his thoughts on return values and reminds you about consistent return types, regardless of the result.



Earlier today, I posted a brief tweet (isn't that redundant?) about return values in PHP (or really, any language). Originally it was about return values from functions (such an exciting topic, I know), but it ended up generating a fair bit of lively conversation, as well as a patch against Drupal 8. So lively, in fact, that I think it deserves more than 140 characters.


He proposes a new rule of thumb: "If your function returns a collection, its null value return must also be a collection." A more broad version of this might be: "make your return types consistent." It's all about predictability and the contracts you have between different parts of your code. If a user calls your method expecting to be able to loop over the results, they'll be disappointed with a "false". He talks some about using and throwing exceptions more effectively for error handling and answers several "but wait..." arguments for his return strategy.

Systems Architect Blog: Apache2 vs Nginx for PHP application


On the Systems Architect blog there's a recent post from Lukasz Kujawa about comparing Apache2 and Nginx for PHP applications, specifically when using the PHP-FPM module. His tests are based on the results from three different application types - a large Zend Framework 1 app, a small PHP script and a WordPress installation.



If you've ever been trying to squeeze more out of hardware you must have come across Nginx (engine x). Nginx usually appears in context of PHP-FPM (FastCGI Process Manager) and APC (Alternative PHP Cache). This setup is often pitched to be the ultimate combo for a web server but what that really means? How much faster a PHP application is going to be on a different web server? I had to check it and the answer as often is - that depends.


He ran the tests on an Amazone EC2 instance and optimized the server to ensure that there was a little interference as possible. The used the Zend Optimizer Plus opcode cache and PHP 5.4 and set the logs to go to memory instead of disk. Graphs included in the post show the results of the benchmarking of each application, with the differences (in most cases) not being that wide of a gap.



There isn't big difference between Apache2 and Nginx in PHP context. Yes, Nginx can be much faster when delivering static content but it won't speed up PHP execution. Running a PHP script seams to be so CPU challenging task that it completely eclipse any gain from a web server.

Zend Framework Blog: Help us improve the documentation!


On the Zend Framework blog they're asking for your help with the project's documentation. They're looking to the users and community members around the framework to help them make the documentation more useful and stay up to date.



A piece of software is only as good as its documentation. The Zend Framework team and a dozen or so contributors are working hard to improve the Zend Framework 2 documentation, but we still want you to help us improve it even more. Any kind of help is welcome and greatly appreciated.


Most of what they're looking for is clarity - they want to ensure that what's in the manual makes sense (and is correct for the release it relates to). They're also looking for feedback on what helps you learn best - tutorials, user guides, API docs, etc. Issues and suggestions should be posted to the issue tracker in github. If you're not sure where to start, check out the contributors guide.

2013年3月28日星期四

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: Packagist Latest Releases for 03.28.2013

Recent releases from the Packagist:

Zend Framework Blog: Zend Framework 1 is Migrating to Git!


The Zend Framework project has announced a major move for the framework's development - the Zend Framework v1 repositories will be moving from Subversion to Git over the next year or so.



Since its inception, Zend Framework 1 has used Subversion for versioning. However, as we approach its end-of-life (which will occur 12-18 months from the time this post is written), and as our experience with ZF2 processes becomes more familiar, we -- the Zend team and the Community Review team -- feel that we can better support ZF1 via GitHub. As such, we will be migrating the ZF1 Subversion repository to GitHub this week. Please read on for details!


The post details the steps that'll be taken during the process including the changing of the location of the "master" branch (and how to change svn to point to it) and the updates to the integration of the Dojo libraries. They also talk some about the "extras" repository and how things will work with the Issue Tracker and pull requests in the future.



The repository and issues migration is the first step in a series of planned migrations. We also plan to eventually migrate our wiki to GitHub; this will allow us to offload functionality from the main ZF website, and also consolidate all development-related functionality (other than the mailing list) in a central location.

NetTuts.com: Round Table #1: Should Exceptions Ever be Used for Flow Control?


On the NetTuts.com site today they've posted the transcript of a panel discussion they had with several developers about exceptions and whether or not they should be used for flow control.



I'm pleased to release our first ever round table, where we place a group of developers in a locked room (not really), and ask them to debate one another on a single topic. In this first entry, we discuss exceptions and flow control.


The opinions vary among the group as to what exceptions should be used for (even outside of the flow control topic). Opinions shared are things like:



  • Exceptions are situations in your code that you should never reach
  • Errors cause Failures and are propagated, via Exceptions.
  • So, essentially, exceptions are an "abstraction" purely to model the abnormality.
  • Personally, I envision exceptions more as "objections."
  • Exceptions like this should be caught at some point and transformed into a friendly message to the user.


There's lots more than this in the full discussion so head over and read it all - there's definitely some good points made.

Lukas Smith: Good design is no excuse for wasting time


In his most recent post Lukas Smith suggests that good design isn't an excuse for wasting time. He's basically saying that Symfony2, because of how it's designed and implemented, isn't a RAD (rapid application development) framework and that it's about time for some layers to be added to help get it there.



Symfony 1.x I would put into a category of frameworks focused on RAD, aka rapid application development. [...] So for those people who were happy focusing on the 80% use case Symfony2 is a step back. Suddenly the same features take longer to implement, take longer to modify later on and on top of that the learning curve is steeper.


He suggests that work be put into "RAD layers" that can sit on top of Symfony2 and provide some of the more familiar features people are used to from things like CakePHP, Yii and CodeIgniter. There's been a few tries to accomplish this with only one getting the closest in his opinion - the KnpBundle.

2013年3月27日星期三

Community News: Latest Releases from PHPClasses.org

Community News: Packagist Latest Releases for 03.27.2013

Recent releases from the Packagist:

Adam Bard: The Same App 4 Times: PHP vs Python vs Ruby vs Clojure


Adam Bard has written up a post that takes the same small application (a "Nurblizer") and writes it as a web application in four different languages - PHP, Python, Ruby and Clojure. His point is less about which is "best" but more to show the differences between them.



Here's a toy program I wrote implemented in PHP, Python, Ruby, and Clojure. I hope it's helpful for someone who knows at least one of those and wants to learn another.
The program is called "Nurblizer", and it does one thing: Accept free-form text, and attempt to replace all words but the nouns in said text with the word "nurble". It's up and running at http://nurblizer.herokuapp.com


He includes the source for each language's version using Sinatra for Ruby and Flask for Python but for PHP and Clojure it's just straight code. For each he briefly explains what its doing and a bit about how it relates to the examples from the other languages. He also points out a Hacker News discussion that's popped up about the examples.

Snipe.net: Sending Mail Using PHP and Amazon SES on Centos/AWS Linux


In this new post to her site Alison shows how to send emails through the Amazon Simple Email Service (SES) from a CentOS instance (an AMI in this case).



If you find yourself using Amazon SES for sending outgoing emails in a PHP web app, getting everything set up is much simpler than it may seem. In my case, this was on an AWS Linux image, but it will work on any Fedora/CentOS AMI. You can, of course, set up sendmail and use a proper MTA to send email from your web app, but in this case, I had inherited the requirement to set up an environment for code that was already written to use SES for outgoing email and Google Apps for incoming emails, so the actual mechanics weren't up for debate.


She includes screenshots showing how to configure the SES system with your site's domains and DNS as well as the email addresses you're planning on using. She links over to the MSMTP software you'll need to install on your instance to make the connection and what you'll need to do to get it configured for PHP's use. A sample email script is also included to test the connection (and where to look to make sure everything worked correctly).

Drupal Motion: PHP is not dead


In this new post to his Drupal Motion site, David Corbacho shares some statistics about why PHP "isn't dead yet" and that despite the slow adoption of the latest versions of the language, it's still as popular as it ever was.



This is a follow-up on the article Dries Buytaert wrote in 2007 PHP is dead... long live PHP!. In the article he shared same concern that Nick Lewis for the slow adoption rate of PHP 5, less than 20% at that time. And he encouraged to upgrade to PHP 5. [...] Well, PHP 5 adoption rate is 96.9%, and PHP 4 is quite dead. Mission accomplished. Let's have a look to the overall PHP health.


He shares data from a few sources about the popularity and adoption of PHP in applications/sites all across the web. Sources include Netcraft survey results, W3Tech usage summaries and Stack Overflow tagging matches (complete with graphs of each set of data).

2013年3月26日星期二

Community News: Latest PECL Releases for 03.26.2013

Latest PECL Releases:
  • ZendOpcache 7.0.1
    - Fixed Bug #64490 (add __FreeBSD_kernel__ to allowed FreeBSD defs)
    - Fixed Bug #64482 (Opcodes for dynamic includes should not be cached)
    - Fixed Bug #64353 (Built-in classes can be unavailable with dynamic includes and Optimizer+)
    - Fixed compatibility with ext/phar
    - Fixed Issue #58 (PHP-5.2 compatibility)
    - Fixed Issue #57 (segfaults in drupal7)
    - Fixed Issue #54 (PECL install adds extension= instead of zend_extension= to php.ini)-iii
    - Allows exclusion of large files from being cached
    - Save a stat() call by calling sapi_module.get_stat()
    - Add optional flag to opcache_get_status()
    - Separate "start_time" from "last_restart_time"


  • xdebug 2.2.2
    Sat, Mar 23, 2013 - xdebug 2.2.2

    + Added features:

    - Support for PHP 5.5.

    = Fixed bugs:

    - Fixed bug #598: Use HTTP_X_FORWARDED_FOR to determine remote debugger.
    - Fixed bug #625: xdebug_get_headers() -> Headers are reset unexpectedly.
    - Fixed bug #811: PHP Documentation Link.
    - Fixed bug #818: Require a php script in the PHP_RINIT causes Xdebug to crash.
    - Fixed bug #903: xdebug_get_headers() returns replaced headers.
    - Fixed bug #905: Support PHP 5.5 and generators.
    - Fixed bug #920: AM_CONFIG_HEADER is depreciated.


  • event 1.5.0
    Fix: uninitialized socket caused segmentation fault in EventBufferEvent methods
    Del: EventBufferPosition class removed, EventBuffer::search now accepts and returns integers
    Add: EventBuffer::searchEol method
    Add: EventUtil::getSocketName method
    Add: EventListener::getSocketName method
    Fix: memory leak due to lack of zend_hash_destroy on the ssl context options
    Add: support of UNIX domain sockets in EventListener::__construct, EventBufferEvent::connect methods


  • pq 0.1.0
    * Initial release


  • taint 1.2.2
    - Fixed issue #4 (wrong op fetched)
    - Fixed issue #3 (zend_error_noreturn undefined)


  • Judy 0.1.5
    - Multiple bug fixes and improvment from GitHub pull request #8


Community News: Packagist Latest Releases for 03.26.2013

Recent releases from the Packagist:

Pádraic Brady: Predicting Random Numbers In PHP - It's Easier Than You Think!


Pádraic Brady has a new post to his site about "randomness" in PHP and how, depending on the method used, you might not be as random as you think.



The Zend Framework team recently released versions 2.0.8 and 2.1.4 to address a number of potential security issues including advisory ZF2013-02 "Potential Information Disclosure and Insufficient Entropy vulnerabilities in ZendMathRand and ZendValidateCsrf Components". Quite the mouthful! In short, Zend Framework used the mt_rand() function to generate random numbers in situations where neither openssl_pseudo_random_bytes() nor mcrypt_create_iv() were available. This is possible when the openssl and mcrypt extensions are not installed/compiled with PHP.


He talks some about the mt_rand function and how it generates its "random numbers" (designed for speed, not ultimate randomness). He notes that all of PHP's internal randomization functions use the concept of "seeds" to prime the random number/string generation. Unfortunately, the seeding method is known inside PHP, so it is possible - if the method of generation is weak, as it is with mt_rand - that an attacker could brtute force their way into a correct value. You can find more about randomness in PHP in this chapter of his PHP security handbook including a mention of Anthony Ferrara's randomness library.

PHPMaster.com: A First Look at React


On PHPMaster.com there's a new tutorial that introduces you to React, the PHP-based event-driven non-blocking socket tool that's similar to some of the functionality Node.js provides. The article is a very basic introduction but can help get your feet wet with the tool.



For the past couple of years, Node.js has been drawing increasing amounts of attention as a promising web technology. While it has some strengths, like being event driven, some people just want to stick to PHP. For over a year now, however, there has been a similar project for PHP named React. React is mostly coded by Igor Wiedler, who is also a prominent contributor to the Silex framework. While reading through the React examples, it really does look similar to Node.js.


Included in the post are the instructions on how to get the latest version of React (via Composer) and the code to create a sample server that just writes out a string with a counter for the number of requests made. There's also an example of a "keystroke logger" for all data that's coming across the connection. The author (Igor) notes, however, that he wouldn't recommend using React in production, though, as its target is mostly those working with "cutting-edge technologies" rather than more stable applications.

Duckout Blog: Do Funny Stuff with the Google Charts API and PHP


In this recent post to the Duckout blog, they show you how to hook your PHP-based (and database driven) application into the Google Charting API for chart/graph generation.



I think, whenever we see a chart in a magazine, in books or applications our brain say's to us Yeepie!!! Don't read these stupid texts or tables! Just look at the green or yellow line and hope that they are above the other lines or hope that your opinion is the biggest part of the pie. This saves us a lot of work and in my opinion we should concentrate on drawing beautiful colorized pie charts, instead of writing long boring articles. But the question is: How do I draw these beautiful colorized pie charts? The simple answer is: you don't have to, because google will draw them for you and you just have to tell them what to draw via the google charts api.


The sample application is a "breakfast rating" tool that logs the results to a MySQL database via PDO calls. The results are then extracted and formated as JSON to be compatible with the Google Charts API data handling. Some sample Javascript is included showing how to call the Charts API with your data and get back a simple line graphing of the data from the database. You can see the application in action here for reference.

2013年3月25日星期一

Community News: Packagist Latest Releases for 03.25.2013

Recent releases from the Packagist:

NetTuts.com: The 11 Phases of a Web Developer's Career (As Illustrated by Memes)


NetTuts.com has started off the week on a humorous note with this latest post showing the "11 Phases of a Web Developer's Career" as illustrated with animated GIFs of various internet memes.



The career of a web developer is an interesting one with many slopes. Considering a learning curve this steep, you can fully expect to live through periods of frustration, enlightenment, self-righteousness, and every mindset in between. In this article, we'll have some fun, by reviewing each of these phases through the lens of a meme!

Some of the phases include:



  • Phase 1 - Noob
  • Phase 3 - Complete Frustration
  • Phase 5 - Fragile Code
  • Phase 7 - Cocky
  • Phase 9 - When Code Becomes Art
  • Phase 10 - Seasoned


Check out the post for the images of these and the others on their "top 11" list.

Lorna Mitchell: First Phing Plugin


In the latest post to her site, Lorna Mitchell walks you through the creation of a first Phing plugin, an extension to the popular PHP-based build tool.



I'm a huge fan of Phing and use it regularly for build and deployment tasks. Often, I'll ask about a plugin that I wish existed, and get a very courteous "patches welcome" from the nice people in the #phing channel on freenode. This has happened a few times, so I thought I should probably look at how to make a new phing plugin, this article shows you how to make the simplest thing I could think of: a simple "hello world" plugin.


She points you to the location to grab the latest version of the tool (the github repository) and how to define a configuration file for your test runs. Then she includes the sample code showing how to create the "HelloTask" plugin. It takes an input value of "name" and displays a greeting when executed. She shows the syntax for defining this in the XML build file and the sample result when executed.

Phil Sturgeon: Pick PHP Requirements for Packages Responsibly


In this recent post to his site Phil Sturgeon has a reminder that you should select the dependencies for your packages wisely, and not just because they're "cool."



When I say "make sure it is worth it" I mean, don't just switch your arrays from array() to [] just because it looks cool. That was the extent of my original tweet, because I've seen a few packages doing that and it annoyed me immensely. [...] Suffice it to say, if you require a user to upgrade their version of PHP simply so you can use some syntactical sugar inside a package that nobody else is even going to be looking at, then you're an idiot. Beyond that, you're actually hurting the community.


He notes that, by requiring users that are currently only at 3.1% of PHP installs to upgrade to 5.4 just to use your library is a quick way to not have your library used. He points out that PHP 5.4 is "more than just []" for arrays and includes a reminder that several projects are still in PHP 5.3-compatibility mode just because that's the widest audience. He also briefly touches on the "push it forward" comments that people have used to justify 5.4-only packages, but notes that it's still not as much up to the developer as it is the web host.

2013年3月24日星期日

Community News: Packagist Latest Releases for 03.24.2013

Recent releases from the Packagist: