2014年1月31日星期五

Site News: Popular Posts for the Week of 01.31.2014

Popular posts from PHPDeveloper.org for the past week:

Community News: Packagist Latest Releases for 01.31.2014

Recent releases from the Packagist:

Benjamin Eberlei: SOAP and PHP in 2014


Benjamin Eberlei has a new post today looking at the future of SOAP in PHP for the upcoming year. In his opinion, despite negative comments and harassment the technology gets, it still has the advantage over REST.



These last years REST has gotten all the buzz, everybody seems to be using it and there are lots of talks about REST on conferences. SOAP used to be big for building APIs, but everybody seems to hate it for various reasons. I have used SOAP in several projects over the last 10 years and this blog post is a random collection of information about the state of SOAP in PHP 2014, as a reminder to myself and to others as well. Why care about SOAP in 2014? For server to server (RPC) communication it still has massive time to market and stability benefits over REST.


He points out some things REST lacks like a standard to describe endpoints and a way to automatically generate clients in any language. He then gets into some of the basics of SOAP and PHP's included functionality. He shows some of the configuration options you can use for things like debug output, exceptions and custom exception handlers. He recommends the Zend Frameworks SOAP Autodiscovery for generating WSDLs and the XSD-TO-PHP library to create objects from a well-defined WSDL. He covers the different modes you can use to "talk SOAP" and using the ZendSoapClientLocal to make a request without the need of a web server.


Link: http://www.whitewashing.de/2014/01/31/soap_and_php_in_2014.html

Christian Weiske: PHP manual viewers


In this latest post to his site Christian Weiske shares three PHP manual viewers he finds useful (besides the actual PHP.net manual) and can be used offline.



The PHP documentation is really good. It covers almost all parts of the language and is filled with examples that help you grasp a function's meaning and usage really fast. And since PHP is a grown language, it's function naming and parameter order are often confusing - requiring you to look up the manual more often.

The three he suggests are:



  • pman - PHP manual pages
  • the xCHM version of the manual
  • Zeal, which also has support for lots of other docs from other languages/tools

Link: http://cweiske.de/tagebuch/php-man-viewer.htm

Pádraic Brady: PHP 5.6 and SSL/TLS: Getting Better But Will PHP Programmers Actually Use It?


In his latest post Pádraic Brady looks at a new addition to PHP (well, to be included in the next release) related to the SSL/TLS handling it provides in streams. He's happy to report that things are improving. This commit integrated an RFC allowing for TLS perr verification in PHP streams.



The RFC reverses PHP's course and provides PHP streams with defaults that enable both peer verification and host verification. The patch implements the RFC and it lets PHP leverage the local system's own certificate stash (e.g. Debian's ca-certificates) where possible to avoid PHP having to distribute a bundle of its own and while also assisting in backwards compatibility. [...] Once we have a PHP streams/sockets system with a passable level of default security, the rest will be left to programmers on the ground to change their practices.


With this new functionality coming in PHP 5.6, he strongly encourages developers to change how they're currently doing things and embrace this new verification to keep their code safer.


Link: http://blog.astrumfutura.com/2014/01/php-5-6-and-ssltls-getting-better-but-will-php-programmers-actually-use-it/

2014年1月30日星期四

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 01.30.2014

Recent releases from the Packagist:

PHP Town Hall: Episode 18: PHPDBG, HHVM and Internals


The PHP Town Hall podcast has released their latest episode today - Episode #18, "PHPDBG, HHVM and Internals". This time the lineup includes Sara Golemon, a developer on the HHVM project, and Joe Watkins, a developer on the PHPDBG project.



Joe Watkins and Sara Golemon join Phil to make one hell of an episode. These two are not only core contributors to PHP, but are behind a lot of RFCs and decisions that make PHP considerably better. We talk about a whole bunch of awesome stuff, including progress of the named parameters RFC - and the chances of it making in, the new accepted PHP 5.6 feature PHPDBG and what it means for you, HHVM and its relationship to "The PHP", wether PHP should have a spec for implementations of the language, and a whole bunch of other stuff.


You can listen to this latest interview in a few different ways - you can either listen with the in-page player, download the mp3 or you can watch the video of the live Google Hangouts recording.


Link: http://phptownhall.com//blog/2014/01/29/episode-18-phpdbg-hhvm-internals/

SitePoint PHP Blog: Arbitrary Precision and Big Numbers in PHP


The SitePoint PHP blog has a new post by Taylor Ren looks at big numbers in PHP and the functionality it has to handle arbitrary precision via three modules - GMP. BC Math and php-bignumbers.



In this article, we will review the PHP capability to provide arbitrary precision number calculation / big integer calculation by reviewing 3 PHP modules: GMP, BC Math and php-bignumbers. We will demonstrate two real-world examples to see the powers/limitations of each. The first one will be calculating PI to arbitrary precision - well, for the sake of the article, we will restrict the precision, say, to 1000 digits; the second will be a simple demonstration on RSA encryption/decryption.


He briefly looks at how to get the tools installed (via at-get or Composer) and a sample script to ensure that they're all included correctly and working. He includes a comparison between the three libraries, listing both strengths and weaknesses relative to the others. He then gets a bit more in-depth and shows how to calculate PI with each option (code is on GitHub) and the results of the benchmarking. He also includes a second example of calculating the RSA algorithm based on their process.


Link: http://www.sitepoint.com/arbitrary-precision-big-numbers-php/

MaltBlue.com: Easy Setter Injection in Zend Framework 2


Matthew Setter has a new post today looking at setter injection of dependencies in a Zend Framework v2 based application. He shows how to do it via ServiceManager-aware interfaces.



For configuring objects, reused throughout the application, I've found it to be nothing short of amazing. With next to no code, one Module configuration setting, along with the magic of OOP, classes are suitably initialized throughout the application, without any hands-on configuration on my part. Whilst Zend Framework 2 is great without this. When you start using setter injection, it becomes so much more. In today's post, I'll take you through an example which uses setter injection to ensure that the AuthService, or authenticated user object is always available to a class and any of its descendants.


He walks you through a basic implementation, showing the creation of the "AuthAwareInterface" interface class and an implementation of it, the "CacheableTable". In the "CacheableTable" there's a setter and getter for the currently authenticated user. Using these he's able to configure the ServiceManager to get the AuthService instance from the service locator and inject it into the class. He also includes a word of warning to be careful with the injection you do use, pointing out that it can lead to difficult to track bugs and issues down the line.


Link: http://www.maltblue.com/zend-framework/easy-setter-injection-in-zend-framework-2

2014年1月29日星期三

Community News: Recent posts from PHP Quickfix

Recent posts from the PHP Quickfix site:

Community News: Packagist Latest Releases for 01.29.2014

Recent releases from the Packagist:

Allan MacGregor: Design Patterns in PHP: Singletons


Allan MacGregor has posted his latest in his look at design patterns in PHP with this most recent post about the Singleton pattern.



The singleton pattern is used to restrict the instantiation of a class to a single object, which can be useful when only one object is required across the system. Singletons are designed to ensure there is a single (hence the name singleton) class instance and that is global point of access for it, along with this single instance we have global access and lazy initialization.


He provides a basic Singleton implementation in PHP, a "User" class that always returns the same instance of itself no matter how many times the "singleton" method is called. He continues on and touches on one of the pain points around singleton use - many developers consider them an anti-pattern because their results can make it difficult to correctly test. He talks about how they break the Single Responsibility Principle (part of SOLID) and how they can hide dependency injection.



Singletons, Anti-patterns, and patterns in general are not good or bad; what makes a Singleton an Anti-pattern is not the pattern itself but how often is poorly implemented and how easy it is to do so.

Link: http://coderoncode.com/2014/01/27/design-patterns-php-singletons.html

Dutch Web Alliance: The definitive remote debug and unittest with PHPStorm guide: part 7


The Dutch Web Alliance has posted the seventh part of their series looking at getting remote debugging and unit testing working with PHPStorm, a popular PHP IDE. You can start at the beginning or just find the links to any other articles in the series you might have missed in the first post.



So, your unit-tests should be small, not doing much, taking one unit at a time to test. Overall, not much is around to actually debug. But on occasion, having the ability to actually stepping through the unit-tests can save you a headache or two! Debugging your PHPUnit scripts isn't really that hard. In fact, most of what we need to do, we already covered in the previous postings! Consider this: PHPUnit is nothing more than a PHP framework running from the command line interface. And since we already know how to debug applications from the CLI, it must be easy!


This is the last post in the series and is pretty short. It basically talks about setting breakpoints in testing and letting PHPStorm catch the issues. If you'd rather run them from the command line, check out part six for more details.


Link: https://dutchweballiance.nl/techblog/the-definitive-remote-debug-and-unittest-with-phpstorm-guide-part-7/

PHPBuilder.com: Implementing Secure Passwords in PHP 5.5


On PHPBuilder.com today there's a new post introducing you to a relatively recent advancement in PHP (in version 5.5), the password hashing API. In this article they cover the basics including hashing and verifying the result.



PHP has always had a few simple ways to implement password hashing to an extent. MD5 and SHA1 are examples of this, but the security of these methods is not what it should be. [...] What we need is a secure password encryption mechanism that uses SALT and perhaps even something else to help us safely encrypt our passwords for later use. [...] Lucky for us, the folks at PHP have thought about this long and hard, and the result is a very simple PHP password hashing API that is not only easy to use, but fast and secure.


They briefly look at the two major functions in the updated feature - password_hash and password_verify and some basic code examples of their use.


Link: http://www.phpbuilder.com/articles/application-architecture/security/implementing-secure-passwords-in-php-5.5.html

SitePoint PHP Blog: Sending Confirmation Emails with Phalcon and Swift


The SitePoint blog has posted a new tutorial by author Thien Tran Duy showing you how to send emails with Swift through a Phalcon-based application via Gmail.



Today, sending emails is considered the basic functionality of any web application. Usually, an email is sent to notify the user of some kind of activity that has taken place on the website, such as when he registers the account, updates information, or when new friends have been found. In this short tutorial I'll show you how to send emails via Gmail quickly from within a Phalcon sample application. You can download the full source code from GitHub. We'll be building functionality which lets us send a confirmation email, and reacts to the click of said confirmation email.


The tutorial walks you through the entire process from start to finish, complete with code examples. It helps you set up the Phalcon project, modify the configuration, set up models and create the basic controller. You'll need to either install Swift via Composer or by just adding the files to the vendor directory though. The script uses this library to send the message, store the hash in an "email_confirmations" table and verify it once the user returns.


Link: http://www.sitepoint.com/sending-confirmation-emails-phalcon-swift/

2014年1月28日星期二

Community News: Latest PECL Releases for 01.28.2014

Latest PECL Releases:
  • APCu 4.0.3
    - Fix various compatibility problems
    - Fix a few lingering faults
    - Remove experimental eval serializer
    - Fix iterator for compatibility


  • protocolbuffers 0.2.1
    This is package.xml maintenance release only.


  • protocolbuffers 0.2.0
    Initial Release


  • swoole 1.6.10
    - Enabled by default async_mysql
    - Add tcp heartbeat mechanism
    - UDP send no require from_id
    - swoole_client on::Receive and on::Close no need to call recv/close
    - Add last_time and connect_time to tcp connection_info
    - rebuild data_buffer


  • ssdeep 1.0.4
    This is a build maintenance release only so there is no need to upgrade.

    - Make use of --with-libdir so installers can override the lib default (RHEL uses lib64 for example)
    - Clean up the build script to standardise the code constructs used
    - Add LICENSE, README and CREDITS to PECL package configuration


  • ssdeep 1.0.3
    Bug #60347 OSX can't build as .so hardcoded


Community News: Packagist Latest Releases for 01.28.2014

Recent releases from the Packagist:

Lorna Mitchell: GitHub-Powered Changelog Scripts


In her latest post Lorna Mitchell has shared some scripts she uses to automate the creation of a changelog based on the GitHub issue comments and fixes.



My current project does periodic releases, we build a few things, then we work on getting a bunch of user feedback and changing/fixing things before we actually release. [...] When a branch merges in to the main line, we use the "fixes #42" notation to simultaneously close off the issue that it relates to. This has been working pretty well, and today I got the question "what's new since I last saw this project?" - so I created a changelog. It's rather rough-and-ready but I had fun so I thought I'd share.


The script operates off of a local git cloned version of the repository and grabs all commit messages with the tern "fixes" in it. The script then takes the log file, matches the issue ID and then makes a cur call out to the GitHub API to get that issue's description. This is then taken, formatted and dropped into the output.


Link: http://www.lornajane.net/posts/2014/github-powered-changelog-scripts

Cal Evans: Let's be honest...


Cal Evans has posted a sort of "call to arms" for the developers out there, asking them to be more honest with software estimates and think realistically about the project and its complexities.



As developers, we see projects not as a job that must be done, but as art that can be created, as a project that needs to be crafted. It's not a spreadsheet of numbers to us, it's a sketch on a napkin of something we want to build. As such, we see the big picture, but miss the details. So when we tell a customer/client/family member "Yeah, I can build that this weekend". In our mind, we mean it. We honestly think the project is simple enough to be built in a weekend. It rarely is though.


He goes on to talk about some of his own experience with the "just a weekend" claims and the over-promising that comes easily to devs. He suggests a few things to link about as you're estimating your next project - can you actually do it (not a "learn on" project) and thinking about when it will be done based on availability, not just desire and work in isolation.


Link: http://blog.calevans.com/2014/01/27/lets-be-honest/

Matthew Turland: How to be a Great Developer


In his latest post Matthew Turland has shared some of his thoughts about how to be a better developer, regardless of the language or skill level you may find yourself at.



I've shamefully ripped off the title for this blog post from what I expect will be a phenomenal session given by Ed Finkler at php[tek] 2014. Sadly, I haven't seen the session and may not be present at the conference. However, I've spoken with Ed and seen him give sessions on several occasions, so I know he sets the bar pretty high. If you've not considered attending the conference and his session, I highly recommend doing so. Ed has plenty of insightful things to say about being a great developer. Today, the subject coincidentally crossed my mind and I realized I had a few things to say on the matter that may also prove useful to others.


He suggests that there are three main qualities that developers need to become better at their craft and, as a positive side effect, work better with other developers around them. These three points are:



  • Humility
  • Patience
  • Imperfection


For each, he briefly explains the topic and makes some practical suggestions for achieving the goal.



These are things I've learned from my own experiences. I state them here realizing that they may be more applicable to me than they are to you. You must form your own opinions and find your own wisdom. [...] In the end, you must find your own path. Regardless of what that path is, I hope you find the passion shared by myself and those who inspire me and I wish you well in your pursuits.

Link: http://matthewturland.com/2014/01/24/how-to-be-a-great-developer/

2014年1月27日星期一

Community News: Packagist Latest Releases for 01.27.2014

Recent releases from the Packagist:

Matt Frost: Getting Talks Selected


If you're considering getting into the world of speaking at an upcoming PHP conference, Matt Frost has some advice for you to help you get started. It can be intimidating, so learn from some of his own experiences as a relatively new speaker in the community.



It's a very busy conference season in and around the PHP Community. [...] These conferences are such a blessing to those who are able to attend, the speakers know their stuff and are very open to sharing and talking outside of their sessions. But you're a smart cookie too! You've got ideas and thoughts and knowledge that other people would like to have, so how do you get in on this? I'm going to tell you how I got into it, your mileage may vary, but hopefully it helps.


He points out that submitting a talk and getting accepted is "a lot like the lotto" sometimes, that you can't win unless you buy a ticket (submit that talk). He looks at a few of the other common questions from beginning speakers - what do I talk about, how do I write an abstract and common first time speaking concerns.



There's no magical elixir that will land you speaking gigs at cool conferences. Everyone that speaks, from the seasoned pro to the up and comer, has worked extremely hard to not only put the talks together; but acquire all the knowledge necessary to give the talk in the first place

Link: http://shortwhitebaldguy.com/blog/2014/01/getting-talks-selected

Erika Heidi: Vagrant Usage Research


If you've never heard of the powerful tool and you need automation around creating and configuring multiple virtual machines, you really should check it out. If you're curious as to how it's being used and what kind of things it's used for, check out this new post from Erika Heidi based on some research she recently did (and a survey she received some good feedback to).



From 11 to 14 of January, 720 Vagrant users from different sources (Twitter, IRC and the official Vagrant mailing list) answered a quick form I created to find out how people are using Vagrant. I'm currently in the process of writing a LeanPub book about this tool, and I was really curious especially about the provisioners usage.


She's put together the results in the form of an easy to read infographic with details about:



  • The most popular provisioners
  • The percentage of boxes running with OS
  • The percentage of languages on the boxes
  • The OS most Vagrant users use


...and finally the answer(s) to the question of "why vagrant?" but I'll leave it to you to read the post to find out that one.


Link: http://www.erikaheidi.com/2014/01/24/vagrant-usage-research/

NetTuts.com: SOLID: Part 3 - Liskov Substitution & Interface Segregation Principles


On NetTuts.com today they've continued their series covering the SOLID development principles with the next letter in the acronym - "L". It stands for the Liskov Substitution & Interface Segregation Principles. The tutorial also talks some about the "Interface Segregation Principle" as they go hand-in-hand.



The concept of this principle was introduced by Barbara Liskov in a 1987 conference keynote and later published in a paper together with Jannette Wing in 1994. Their original definition is as follows: "Let q(x) be a property provable about objects x of type T. Then q(y) should be provable for objects y of type S where S is a subtype of T." [or more simply] "Subtypes must be substitutable for their base types."


They include some example PHP code showing a base "Vehicle" class and first an example of doing it correctly (with the Template design pattern) and an example of an incorrect method, complete with tests. They then get into the Interface Segregation Principle, an interface that can be depended on to use the module, with the same car-related examples.


Link: http://net.tutsplus.com/tutorials/php/solid-part-3-liskov-substitution-interface-segregation-principles/

SitePoint PHP Blog: HHVM vs Zend Engine in PHP 6


In this recent post to the SitePoint PHP blog Bruno Skvorc compares two technologies that have influence how PHP performs - the HHVM (HipHop Virtual Machine) and the Zend Engine in PHP6 - and the potential replacement of one with the other.



The fabled PHP 6 is long overdue. This unicorn of the web dev world has been "coming" for decades now, and it's still not clear whether or not it's actually something that's going to happen in this decade, or just an idea, a fantasy of the PHP userbase. [...] In the latest edition [of the PHPClasses podcast] between Manuel Lemos and César Rodas, an interesting topic arose among others - Facebook's HHVM replacing Zend Engine in PHP 6. While this was purely speculation on the part of the participants, and whether or not you believe in PHP 6, you have to admit it's an interesting notion.


He starts with a look at the overall pros of the HHVM solution - the speed of execution, that it's backed by Facebook and its support for static typing. There's some cons that come with the HHVM though, including not allowing custom extensions, that it's developed by Facebook (yes, this can be a con too) and that there are other ways to enhance PHP's execution speed without sacrificing other functionality.


Link: http://www.sitepoint.com/hhvm-vs-zend-engine-php-6/

2014年1月26日星期日

Community News: Packagist Latest Releases for 01.26.2014

Recent releases from the Packagist: