2014年7月31日星期四

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 07.31.2014

Recent releases from the Packagist:

Master Zend Framework: Accessing ServiceManager Services in Controller Plugins


Matthew Setter has posted another new tutorial to his Master Zend Framework site today showing you how to access ServiceManager services in controller plugins. Controller plugins are a Zend Framework feature that allows certain events to trigger the plugin code during the lifetime of the controller.



I've seen some questions on Google+ and StackOverflow of late, regarding how to get access to the Zend Framework 2 database adapter, along with other ServiceManager-defined services, in a custom controller plugin. This type of setup can come in handy for a number of situations. You may want to access services such as caching, logging or databases and want to provide a simple interface for doing so. People seem really interested in how to do it, but how to get access to services from the ServiceManager doesn't seem to be as clear as it could be. Gladly, there's not much involved in actually doing it.


He shows you how to create a plugin for an existing module, creating the two needed classes and adding a new function to configure it. He starts with the plugin factory that can be used to generate an instance of the plugin. Next is the plugin class itself that extends the abstract plugin and controller plugin classes. The required database adapter is injected into it via a constructor injection. Finally, in the Module.php configuration, he creates a "getControllerPluginConfig" method that registers the new plugin and points to its class. A screencast is also provided showing the active development of the code.


Link: http://www.masterzendframework.com/servicemanager/accessing-servicemanager-services-controller-plugins

SitePoint PHP Blog: Using Guzzle with Twitter via Oauth


Continuing on with his series about using the Guzzle PHP HTTP library, Miguel Ibarra Romero is back with this new post showing how to connect your PHP application, via Guzzle, to the Twitter OAuth protected service.



In a previous article, we found out about Guzzle and how it can aid us in the task of establishing communication with third party APIs over HTTP. We used it to get the output of a random number generator and for basic interaction with Github's API. [...] While interacting with Github's API we discovered that it supports basic authentication (sending plain username/password). But what if the API we want to use just offers OAUTH authentication?


He shows how to use Guzzle's own OAuth subscriber to make a basic connection to the API. He walks you through the installation of the subscriber (via Composer) and an example of its use. He explains each part of the code, giving a little background on where it fits into the OAuth request and where to put your API secret and key to make the connection work. Finally, he includes the code to handle the callback once the OAuth request is successful, grabbing the token data and adding it to the user session.


Link: http://www.sitepoint.com/using-guzzle-twitter-via-oauth/

PHP Town Hall: Episode 29: Dont Mention PHP 6 v PHP 7


The PHP Town Hall podcast has released their latest episode, hosted by Phil Sturgeon and Ben Edmunds - Episode #29: Don't Mention PHP 6 v PHP 7. In this episode they're joined by guests Paul Jones and Daniel Lowrey.



Paul has recently been talking a lot about "Action Domain Responder" which is billed as a more representative replacement of the often mis-used "Model View Controller" architecture. Luckily he does a good job of ELI5 so we don't get too lost, and we talk a bit about how ADR helps with putting content negotiation in a logical place. Daniel then goes on to talk about a few awesome topics, including some of the OpenSSL changes in 5.6, and a HTTP server he is working on built entirely from PHP. It's async, non-blocking and web-scale.


They also talk about HTTP2, the Aura framework and the PSR-7 HTTP messaging proposal. You can listen to this latest episode either through the in-page audio player, by downloading the mp3 or you can watch the live recording from the Google+ session.


Link: http://phptownhall.com//blog/2014/07/30/episode-29-dont-mention-php-6-v-php-7/

Three Devs & A Maybe Podcast: The First Q&A Show with Justin DeLucia


The Three Devs & A Maybe podcast has posted their latest episode with guest Justin DeLucia. In this new episode they try out something different - a full, dedicated Q&A episode.



This week we have good friend of the show Justin DeLucia on to help host our first dedicated Q&A episode. Not only that, but Fraser is back! along with some crazy adventures that he discusses since his last time on the show. We have been fortunate to receive many questions throughout the past couple of weeks, and thought it would be good to release the answers as a dedicated show. Topics discussed include, breaking into the industry, the PDO vs. Mysqli debate, bespoke vs. off-the-shelf CMS debate and what to consider when building a Web API.


Other topics mentioned in this latest episode include: the Doctrine project, mutual recursion, Laravel Forge and Phil Sturgeon's book Build APIs You Won't Hate. You can listen to this latest episode either through the in-page player or by downloading the mp3 directly. If you enjoy the show, consider subscribing to their feed too.


Link: http://threedevsandamaybe.com/posts/the-first-qa-show-with-justin-delucia/

2014年7月30日星期三

Community News: Packagist Latest Releases for 07.30.2014

Recent releases from the Packagist:

Voices of the ElePHPant: Interview with Joel Clermont


The Voices of the ElePHPant podcast has posted their latest episode in their series of community interviews. This time it's with Joel Clermont, an organizer of the Milwaukee PHP User Group.



They talk some about a newsletter Joelputs out "learning how to learn" based around a conference talk he's proposed/given. Joel also mentions the book he's working on following the same topic. They also talk some about his involvement in the Milwaukee user group.



You can listen to this latest episode either through the in-page audio player or by downloading the mp3 directly. If you like what you hear, consider subscribing to their feed too.


Link: http://voicesoftheelephpant.com/2014/07/29/interview-with-joel-clermont

SitePoint PHP Blog: Understanding OpCache


On the SitePoint PHP blog there's a new tutorial posted helping you understand OpCache, the caching engine built into PHP versions 5.5 and above. This cache isn't designed to cache data or other content, though. An OpCache caches "opcodes" when a script is executed.



PHP in version 5.5 comes with a caching engine built-in - OpCache - which stores precompiled script bytecode in the memory. If you're familiar with APC or Xcache, you will already know how such engines work. As each PHP script is being compiled at runtime, a part of the execution time gets used for transforming the human readable code into code that can be understood by the machine. A bytecode cache engine like OpCache, APC or Xcache does it only once - during the first execution of a specific PHP file. Then the precompiled script is being stored in memory, which should lead to performance boosts in your PHP applications.


The remainder of the article is a series of answers to some common questions about using the cache, what it will do for your applications and some tools to use for tuning and status updates:



  • Is OpCache worth installing at all? What speed boost can I expect?
  • I already use APC cache. Should I migrate to OpCache?
  • How to check if OpCache is actually caching my files?
  • Is there any framework-specific config that I should set?
  • I keep my app config in a PHP file. Can I prevent it from being cached?
  • How can I run both a development and a production environment on a single server where OpCache is enabled?

Link: http://www.sitepoint.com/understanding-opcache/

Community News: PHP Specification in Development


In a recent message to the PHP internals mailing list Sara Golemon has announced the development of a PHP specification, a document formally defining the interfaces and structure of the functionality of the language. The effort is being spearheaded by a group at Facebook.



We (As in PHP) have been talking about making a spec for the PHP language for a LONG time. With PHPNG around the corner, the need for a formal spec is even more important so that we can reliably ensure that PHP.Next matches PHP 5.6's behavior as much as possible. Meanwhile, other implementations of PHP (like HHVM) should be as spec compliant as possible so that we don't see the language bifurcate. To that end, we (as in Facebook), have been putting together a formal language spec for PHP (using PHP 5.6 as the source of truth) along with an additional conformance test suite (which compliments Zend/tests).


An initial version (a "sneak peek") has already been posted providing a great start to the effort. There's already been a lot of support for the project in the community and some of the concerns around workflow and maintenance are already starting to be addressed.


Link: http://grokbase.com/t/php/php-internals/147p423vvz/php-language-specification

Kinsta.com: Real-World WordPress Benchmarks with PHP5.5 PHP5.6 PHP-NG and HHVM


The Kinsta.com blog has a new post with the results of some benchmarking they've done around WordPress comparing PHP 5.5, PHP 5.6 (PHPNG) and HHVM in response time (well, time taken for the request).




If you remember we wrote an article a good couple of months ago when WordPress 3.9 came out that HHVM was fully supported beginning with that release, and we were all happy about it. The initial benchmark results showed HHVM to be far more superior than the Zend engine that's currently powering all PHP builds.



[...] Obviously you have to compromise based on your (or rather your sites') needs but is it worth it? How much of a performance gain can you expect by switching to HHVM? [...] Today I finally took the time to set up a test environment and do some tests to compare a couple of different builds with a fresh out of the box WordPress install and one that has a bunch of content added plus runs WooCommerce!




The testing was all done locally on virtual machines (using Vagrant setups) and two different kinds of test WordPress installations. They share the results in the post, showing the differences between the HHVM installations and the plain PHP ones. The results also show the differences between having the opcode cache on and off. Curious to see how it would perform outside of a local system, they also pushed the same configurations out to a DigitalOcean instance with some slightly different results.


Link: https://kinsta.com/blog/real-world-wordpress-benchmarks-with-php5-5-php5-6-php-ng-and-hhvm/

2014年7月29日星期二

Community News: Latest PECL Releases for 07.29.2014

Latest PECL Releases:
  • SeasLog 1.0.0
    - First version for pecl.net


  • binpack 1.0.0
    - first release


  • sync 1.0.1
    - Fixed Reader-Writer objects.
    - Removed a lead from package maintainers list.


  • yac 0.9.1
    - Try to fix windows build


  • yac 0.9.0
    - first release


  • ibm_db2 1.9.6
    Fixed: Fetching of mixed character data when the application code page different from database code page
    Fixed: db2-bind-param with INOUT LOB parameters
    Enhanced: Enable iSeries system naming mode from LUW to iSeries
    Enhanced: Clear global error state at end of request


Community News: Packagist Latest Releases for 07.29.2014

Recent releases from the Packagist:

Sameer Borate: Downloading Gmail attachments in PHP - an update


Sameer Borate has posted an update to a previous post of his about downloading attachments in PHP. In this new post he updates the script to remove any other dependencies other than the IMAP PHP extension.



As mentioned in the earlier post, automatically extracting attachments from Gmail can be important for reasons where you need to process the attached files periodically with a CRON job or need to process the files programmatically. Also it can be useful for automatically archiving important attachments. [The code in this post] is a simple proof-of-concept plain PHP code, devoid of any object-oriented features that extracts attachments from your Gmail account.


The example code makes a request to the Gmail IMAP servers with the given username and password, grabs the first set of emails, parses their attachments to pull them down to the local host. He also includes some searching capability to locate ones only matching certain criteria. A list of the allowed search keywords is also included. He finishes the post with a look at using READONLY mode and fetching the email headers.


Link: http://www.codediesel.com/php/downloading-gmail-attachments-in-php-an-update/

Expert Developer: Install PHP CodeSniffer on Windows Machine


On the Expert Developer site there's a new tutorial showing you how to get the PHP CodeSniffer tool up and working on a Windows installation. PHP CodeSniffer provides functionality to enforce standards and best practices in your application's development (providing code quality).



In this article we will focus on improving Code Quality. Very first step towards improving code quality is to maintain coding standards across developers. [...] Here we will talk about PHP CodeSniffer, which help us to maintain coding standard across multiple developer. Dealing with CodeSniffer is much easier: create rule set, validate your file against your rule set and get the result immediately. It will immediately show how many mistakes you have made in terms of following coding standards and eventually all developer will start coding as per coding standards you have defined.


There's two main parts to the article: first is getting PEAR installed (a package manager for PHP) and then using it to install CodeSniffer. Complete instructions and commands are included as well as a few screenshots along the way.


Link: http://www.xpertdeveloper.com/2014/07/install-php-codesniffer-on-windows-machine/

NetTuts.com: Understanding and Working with Data in WordPress


On NetTuts.com there's a new post for those new to WordPress (or just wanting to figure out more about the internals of the tool) showing how some of the data is structured and how to work with it.



Most WordPress users never come into direct contact with the database and may not even be aware that it's constantly working to populate their site. When WordPress serves up any kind of page, be that the home page, a single post or page or an archive, it's accessing the database to bring up content that editors and administrators have added to the site. In this series of tutorials I'll look in detail at different aspects of the WordPress database.


This post is the first in the series and provides an overview of the database and what kinds of information each one contains. They talk about content types and provide the table structure and relations in a handy graphical form (an ERD). They then go through each of the tables and describe what the data is including link tables, joining the content in different places.


Link: http://code.tutsplus.com/tutorials/understanding-and-working-with-data-in-wordpress--cms-20567

PHPBuilder.com: Creating Real Time Applications with PHP and WebSockets


On PHPBuilder.com today there's a new tutorial introducing you to the combination of PHP and WebSockets to make real-time requests to fetch data in your application.



This article will explore the main PHP libraries used to create real time, bi-directional applications between clients and servers over WebSockets. WebSocket is full-duplex client/server communication over TCP. It is also a new feature available in browsers as a part of the HTML5 specs that allows JavaScript clients to open bi-directional socket connections to a server. [...] WebSocket connections are basically TCP socket connections that following the WebSocket rules to communicate. The WebSocket Protocol is an independent TCP-based protocol.


They introduce some of the basic concepts behind WebSockets (including an example URL) and show how to use the PHPWebSockets library to handle some sample requests. They also include some basic JavaScript to make the request to the backend PHP script and send or fetch content on the server. They also show you how to implement a simple chat server using a few other libraries like Ratchet, Elephpant.io and Socket.io.


Link: http://www.phpbuilder.com/articles/application-architecture/optimization/creating-real-time-applications-with-php-and-websockets.html

2014年7月28日星期一

Community News: Latest PEAR Releases for 07.28.2014

Latest PEAR Releases:

Community News: Packagist Latest Releases for 07.28.2014

Recent releases from the Packagist: