PHPDeveloper.org

Cees-Jan Kiewiet: AWS PHP SDK Asynchronously

Tue, 06/30/2015 - 17:31

Cees-Jan Kiewiet has a new post today talking about some interesting trickery he was able to do with the AWS (Amazon Web Services) PHP SDK to allow requests to be made asynchronously.

Just got off the AWS SDK for PHP Office Hour hangout and it was great talking with both team members Jeremy and Michael. And one of the things we talked about was async access to the AWS services using the PHP SDK. The goal of this post is to get the AWS PHP SDK client working asynchronously.

He starts with brief instructions on getting the SDK installed (via Composer) along with a library of his own that brings in a few other dependencies. The ReactPHP event loop is what makes the asynchronous connections possible. He includes the code to create the new handler stack and how to use it to make the asynchronous calls. A demo screencast is also included in the post to illustrate the output from a simple set of requests.

Link: http://blog.wyrihaximus.net/2015/06/aws-php-sdk-asynchronously/

SitePoint WordPress Blog: The WordPress Plugin Boilerplate Part 2: Developing a Plugin

Tue, 06/30/2015 - 16:07

The SitePoint WordPress blog has posted the second part of their series covering the creation of a WordPress plugin with the help of the WordPress Plugin Boilerplate. In this latest article they build on the first part of the series and start in on the actual plugin development.

In the first part of my series, an introduction to the WordPress Plugin Boilerplate, we looked at how the code is organised within the Boilerplate. To continue with this series, we'll apply what we've learnt previously to build a real working plugin. We are going to take a look at how quickly we can get our plugin up and running using the Boilerplate code, with as little work as possible. This article will focus on creating and activating the plugin, as well as developing the admin facing functionality of the plugin.

They show you how to create a simple "time since posted" plugin with a few customizations available. They show how to use the Boilerplate generator to set up the basic plugin file structure and installing it on your WordPress application. From there they show you how to create a simple "Settings" page for the plugin and making it work via the functionality Boilerplate offers. The post then shows how to register the plugin, populate the options page and saving the changes the user makes.

Link: http://www.sitepoint.com/wordpress-plugin-boilerplate-part-2-developing-a-plugin/

PHPClasses.org: Book Review - Modernizing Legacy Applications In PHP

Tue, 06/30/2015 - 15:39

The PHPClasses.org site has posted a book review of Paul Jones' "Modernizing Legacy Applications" ebook today covering some of the content in the book and the reviewers own personal opinions on what was good and what could use improvement.

The current technologies we have today and the numerous improvements to the PHP programming language, makes our legacy applications operate "below today's standards". They need to be improved or rewritten, but who would want to rewrite an application of many thousands or millions of lines of code?

That's why you should read this book, 'Modernizing Legacy Applications in PHP' by Paul M. Jones. It explains the nitty-gritty of how PHP applications were built over a decade ago and why they are now called legacy applications. He explains why your legacy applications are not meant to be rewritten, but optimized and improved to support today's standards.

The reviewer goes through each chapter of the book, giving an overview of each including topics discussed and a few of the handy tips. Overall he recommends the book not only to those experienced in the industry but also those new to developing in PHP, helping to prevent bad behaviors before they start.

Link: http://www.phpclasses.org/reviews/id/mlaphp.html

Voices of the ElePHPant: Interview with Sammy K. Powers

Tue, 06/30/2015 - 14:50

The Voices of the ElePHPant podcast, hosted by Cal Evans has posted their latest episode featuring yet another interview with a member of the PHP community. In this latest episode Cal talks with Sammy Powers.

Cal and Sammy talk about his PHP Roundtable podcast and why he (Sammy) started it up. Cal also asks Sammy his opinion of the PHP community as he's a relatively new addition to conferences and the wider community as a whole.

You can listen to this latest episode either through the in-page player or by downloading the mp3. You can also subscribe to their feed to get the latest episodes as they're released. Also be sure to check out the PHP Roundtable podcast!

Link: https://voicesoftheelephpant.com/2015/06/30/interview-with-sammy-k-powers/

Community News: Latest PECL Releases for 06.30.2015

Tue, 06/30/2015 - 13:05
Latest PECL Releases:
  • SeasLog 1.2.0 - Fixed SeasLog::analyzerDetail() function compatible with MAC - Fixed memory leak - Support windows

  • hprose 1.5.5 Use zend_ce_throwable introduce in 7.0.0alpha2.

  • rrd 2.0.0beta3 - better default time parameter handling for RRDUpdater:update - zend_string in zend_parse_parameter if possible - 'p' for paths in zend_parse_parameter (remi) - zend_object must be the last member of the own object struct - uggh - (remi) - PHP_FE_END instead of 3 times NULL in zend_function_entry - uggh - (remi) - zend_object_properties_size() usage (remi) - size_t for string parameters length (remi) - huge thanks to remi :)

Laravelista.com: JSON Web Token Authentication for Lumen

Mon, 06/29/2015 - 18:07

The Laravelista.com site has a new tutorial posted showing you how to integrate JSON Web Tokens (JWT) into a Lumen application. JWTs provide a simple, portable way to share authentication and session information in a more robust way than just a single randomly generated token.

This is my third post on how to build an API with Fractal, but in this post I will be focusing on authentication using JWT (JSON Web Tokens). [...] In Build an API with Lumen and Fractal I have shown you a way of creating an API using Lumen and Fractal. In this post we will continue with the same project called Treeline and implement authentication and protected routes. Also at the very end of the post is a small chapter on when to use Lumen over Laravel.

They make use of the tymon/jwt-auth library to handle the actual JWT functionality including a service provider making it simple to integrate. They talk about "improving Lumen" by adding a configuration directory for the JWT package to put its configuration file. From there they add in the necessary facades and configuring the library itself. Next comes the actual authentication handling that, post login, generates the token and resending it along with each response. Finally, they show you how to set up the protection on routes and verifying the token contents on each request.

Link: http://laravelista.com/json-web-token-authentication-for-lumen/

Aaron Piotrowski: Throwable Exceptions and Errors in PHP 7

Mon, 06/29/2015 - 17:45

Aaron Piotrowski has a new post to his site talking about a feature of the next major release of the PHP language (PHP 7) around error and exception handling: working with throwable exceptions and errors.

Handling fatal errors in the past has been next to impossible in PHP. A fatal error would not invoke the error handler set by set_error_handler() and would simply halt script execution.

In PHP 7, an exception will be thrown when a fatal and recoverable error (E_ERROR and E_RECOVERABLE_ERROR) occurs, rather than halting script execution. Fatal errors still exist for certain conditions, such as running out of memory, and still behave as before by immediately halting script execution. An uncaught exception will also continue to be a fatal error in PHP 7. This means if an exception thrown from an error that was fatal in PHP 5.x goes uncaught, it will still be a fatal error in PHP 7.

He goes on to talk about the new interface that both Fatals and Errors implement to make catching them possible in PHP7: Throwable. He provides an example of what the interface would look like in PHP code and how to catch them (a simple try/catch). He then gets into each of the types and looks at the error and exception types they cover including TypeError, ParseError and AssertionError. He also includes an interesting part at the end of the post showing you how to write your error/exception handling to work correctly with both PHP 5 and PHP 7 at the same time.

Link: https://trowski.com/2015/06/24/throwable-exceptions-and-errors-in-php7/

SitePoint PHP Blog: Mobile App Development with Zend Studio

Mon, 06/29/2015 - 16:14

On the SitePoint PHP blog they've posted a new tutorial from Daniel Berman about using Zend Studio to create mobile applications in the same interface you're using (if you're a Zend Studio user) to create your PHP applications.

The world has turned mobile. This is not new, and it should therefore be no surprise to anyone that the results of the 2015 DevPulse survey by Zend show that a vast majority of PHP developers are working on, or intend to work on, mobile apps.

Mobile app development poses many challenges for developers, one of which is tying in the front end of the mobile application with the back-end web service APIs. This tutorial describes how to simultaneously create, test and modify both the front and back end of a modern mobile app using Zend Studio's mobile development features.

He breaks the rest of the post up into several steps to help you get a simple mobile project up and running, complete with a basic Apigility API backend:

  • Creating a Cloud Connected Mobile Project
  • Previewing your App
  • Developing the Back-End APIs
  • Developing the Front-End
  • Testing as an Android Native App
  • Exporting a Native Application Package

The end result is a simple "cloud connected" application that can be installed directly on an Android device as a ".apk" package.

Link: http://www.sitepoint.com/mobile-app-development-zend-studio/

Matt Stauffer: Sublime Text (3) for PHP Developers

Mon, 06/29/2015 - 15:25

Matt Stauffer has posted a set of helpful hints for developers using Sublime Text (3) to help make them more efficient and writing code much easier.

A lot of folks in the PHP community have been checking out PHPStorm lately, including myself and most of the developers I work with. We love the code intelligence we get from PHPStorm, but still miss the speed, quick boot-up, and convenience of Sublime Text. Before I blindly assume PHPStorm is the only way to go, I wanted to see: Can I bring the things a PHP-focused IDE provides PHP developers back to Sublime Text and get the best of both worlds?

He starts with a list of "must haves" for him to be able to move from PHPStorm, features it provides that Sublime, an editor not IDE, might not come with out of the box. Most of his suggestions use the Package Control functionality in Sublime so you'll need that installed to try out his examples. He then shows several tools you can install including:

  • Sublime PHP Companion (package)
  • AllAutocomplete (package)
  • Cmd-click for function definition
  • Integrating Code sniffing and PHP_CodeSniffer
  • DocBlockr (package)
  • Git helpers

...and many more. If you're a Sublime Text user, definitely take a look at his list and see if you can find something to help make your development easier.

Link: https://mattstauffer.co/blog/sublime-text-3-for-php-developers

That Podcast: Episode 20: The one where we don't really prefer this over that

Mon, 06/29/2015 - 14:16

That Podcast, hosted by PHP community members Beau Simensen and Dave Marshall has posted their latest episode: Episode #20, The one where we don't really prefer this over that.

Beau and Dave get in to PSR-7 and how we might be doing middlewares, framework or no framework, container PSR or not and a whole bunch of other stuff as usual.

Other topics mentioned in this episode include: Gun.io, Yuml.me, the MySQL workbench and Homebrew. There's also several mentions of other community members including Jeremy Lindblom, Brian Fenton, Erica Heidi and Dustin Wheeler. You can listen to this latest episode either using the in-page player or by downloading the mp3 directly. If you enjoy the show, be sure to subscribe to their feed too!

Link: https://thatpodcast.io/episodes/episode-20-the-one-where-we-don-t-really-prefer-this-over-that

Community News: Latest PEAR Releases for 06.29.2015

Mon, 06/29/2015 - 13:08
Latest PEAR Releases:

Frank de Jonge: Packages vs. Components: The Dependency Problem.

Fri, 06/26/2015 - 17:12

In a new post to his site Frank de Jonge makes a distinction between packages versus components, pointing out that components are always packages but packages are not always components, and what it really boils down to is a problem of dependency.

The PHP landscape has fully transitioned into its Package Age™ [...] However, due to PHP's nature, there are some problems. While packages are great for re-use outside of frameworks, dependencies are still an issue. Namespaces resolve conflicts between classnames, but they do not offer a solution to package versioning. Especially in a framework-context, this can become very problematic. A real-world-example for this is Guzzle.

In his Guzzle example he describes the main problem - when packages restructure or make changes incompatible with prior versions and dependencies conflict and both must be installed. He also points out that, while this is bad for just packages, it can be made even worse working with components (his name for framework-based packages). Problems he mentions are the previously mentioned dependency conflicts but also some unexpected quirks with how Composer chooses to install packages. He gives an example of this second one with the installation of the Symfony EventDispatcher component and how, upon closer inspection, Composer seems to be installing two versions of the library at once.

Link: http://blog.frankdejonge.nl/packages-vs-components/

NetTuts.com: Programming With Yii2: AuthClient Integration With Twitter, Google and Other Networks

Fri, 06/26/2015 - 16:58

NetTuts.com has posted the latest part of their "Programming with Yii2" series today, this time with a focus on AuthClient integration allowing for easy interfacing with social services like Google or Twitter.

In this Programming With Yii2 series, I'm guiding readers in use of the newly upgraded Yii2 Framework for PHP. In this tutorial, I'll guide you through integration of the built-in AuthClient support to provide sign-in from third party networks such as Twitter, Google and Facebook.

For these examples, we'll continue to imagine we're building a framework for posting simple status updates, e.g. our own mini-Twitter, using our hello codebase. Use the GitHub links on this page to download the code repository. In Programming With Yii2: Integrating User Registration, I walked through integration of the Yii2-User library for user registration and authentication. In this tutorial, we'll learn how to integrate AuthClient with Yii2-User and override its views.

The tutorial starts off with a look at AuthClient: what it is, what it supports out of the box and which they'll be integrating (Google and Twitter). He shows you how to install the library via Composer and where to configure it, including the keys or secrets needed to connect to the provider of choice. For Twitter, he shows how to register a new "application" on their side and how to hook it into your own application and code. He advocates using an ".ini" file outside of the code to store the service credentials too. Finally he shows how to integrate it with the frontend, including the widget to override the default user login handling.

Link: http://code.tutsplus.com/tutorials/programming-with-yii2-authclient-integration-with-twitter-google-and-other-networks--cms-23489

DigitalOcean Community Blog: How To Deploy a Basic PHP Application using Ansible, Part2

Fri, 06/26/2015 - 15:53

Digital Ocean has continued their series about deploying "advanced PHP applications" on an Ubuntu instance via Ansible in part two of the series. If you missed the first part of the series, you can check it out here.

This tutorial is the second in a series about deploying PHP applications using Ansible on Ubuntu 14.04. The first tutorial covers the basic steps for deploying an application, and is a starting point for the steps outlined in this tutorial.

In this tutorial we will cover setting up SSH keys to support code deployment/publishing tools, configuring the system firewall, provisioning and configuring the database (including the password!), and setting up task schedulers (crons) and queue daemons. The goal at the end of this tutorial is for you to have a fully working PHP application server with the aforementioned advanced configuration.

You'll need to finish the first tutorial if you want to follow along here. They pick up where they left off to finish the whole process, starting with a switch to a more advanced example repository. They modify the Ansible configuration and run the playbook to update the host. From there they break things down into several more steps:

  • Setting up SSH Keys for Deployment
  • Configuring the Firewall
  • Installing the MySQL Packages
  • Setting up the MySQL Database
  • Configuring the PHP Application for the Database
  • Migrating the Database
  • Configuring cron Tasks
  • Configuring the Queue Daemon

While a good bit of these steps relate to something Laravel needs (what they use for the sample application), it's still a good overview of the wide range of things you can do with Ansible during deployment.

Link: https://www.digitalocean.com/community/tutorials/how-to-deploy-an-advanced-php-application-using-ansible-on-ubuntu-14-04

SitePoint PHP Blog: 4 Best Chart Generation Options with PHP Components

Fri, 06/26/2015 - 14:30

The SitePoint PHP blog has a new article posted sharing four of the best charting libraries they've seen for use in your PHP applications. Options include both server and client side tools, making finding one for your situation easier.

Data is everywhere around us, but it is boring to deal with raw data alone. That's where visualization comes into the picture. [...] So, if you are dealing with data and are not already using some kind of charting component, there is a good chance that you are going to need one soon. That's the reason I decided to make a list of libraries that will make the task of visualizing data easier for you.

He starts with a brief comparison of the server side versus client side options, pointing out some high level advantages and disadvantages of each. He then gets into each of the libraries, giving an overview, an output example and some sample code to get you started:

  • Google Charts (Client Side)
  • FusionCharts (Client Side)
  • pChart (Server Side)
  • ChartLogix PHP Graphs (Server Side)

He ends with a wrapup of the options and links to two other possibilities you could also evaluate to find the best fit.

Link: http://www.sitepoint.com/4-best-chart-generation-options-php-components/

Joe Ferguson: How I use Laravel Homestead everyday

Thu, 06/25/2015 - 15:21

Joe Ferguson has a new post to his site sharing a bit about how he uses Homestead (the Laravel project's virtual machine offering) in his every day development.

I feel like I've been talking about homestead a lot lately. I feel like Vagrant is such an important part of a developer's workflow. If you are still using MAMP, WAMP, or installing Virtual Machines manually you are wasting so much of your own time (and your clients money) by not using prebuilt development environments. [...] I prefer to have my open source projects contain a Vagrant environment so that any potential contributor can easily clone my repository and run "vagrant up". [...] The recent changes to Homestead have brought the option to use Homestead exactly as I do, without having to use my own packages or copy and paste files.

He walks you through the simple process of getting a project set up with this Homestead-per-project configuration:

  • Starting a new Project
  • Adding Homestead as a dependency
  • Make the Homestead configuration for this project

Now when a "vagrant up" is run from the project, Vagrant understands to create a Homestead virtual machine instance, import the base box and configure it to be a locally hosted web server for your application. He also includes instructions for using it with non-Laravel applications and how to share the environment.

Link: http://www.joeferguson.me/how-i-use-laravel-homestead-everyday/

Laravel Podcast: Episode 30: Trouble, Trouble, Trouble...

Thu, 06/25/2015 - 14:50

The Laravel Podcast, hosted by Matt Stauffer (with regular guests Taylor Otwell and Jeffrey Way) has posted their latest episode today - Episode #30: Trouble, Trouble, Trouble....

In this episode, the crew discusses architecture driven religious wars and the recent drama surrounding Apple Music.

You can listen to this latest episode either through the in-page audio player, by downloading the mp3 or by subscribing to their feed to get this and future episodes as they're released. Be sure to also follow them on Twitter for announcements when new episodes are released.

Link: http://www.laravelpodcast.com/episodes/13327-episode-30-trouble-trouble-trouble

Kévin Dunglas: Using PSR-7 in Symfony

Wed, 06/24/2015 - 18:50

With the recent acceptance of the PSR-7 HTTP standard by the PHP-FIG, there's been a lot of articles about using it in various PHP frameworks. In this new post Kevin Douglas looks at the use of it in Symfony, how it relates to the HttpFoundation component and when it will be included in the framework itself.

Back in 2011, Symfony 2 introduced the HttpFoundation component, a PHP library representing HTTP messages with an object oriented API. HttpFoundation is a key in the success of the HTTP-centric approach of Symfony, and it definitely inspirited the PSR-7 specification. However, PSR-7 and HttpFoundation differ fundamentally in two aspects: PSR-7 messages are immutable, mutability is in the DNA of HttpFoundation and in PSR-7, almost everything is stream.

Because of immutability it is very hard to make HttpFoundation embracing PSR-7 without a huge backward compatibility break impacting thousands of existing applications and bundles.

Work was almost immediately started to support the PSR-7 specification in Symfony, however. As a result support will be ready to be included in Symfony 2.7 but, as the rest of the post shows, it can be introduced in versions 2.3 or greater through a "HTTP message bridge" library. He shows how to get this installed in your Symfony application instance and how to use it in your controllers to interact with Requests and Responses. He does point out, though, that while this can bring your release up to PSR-7 status it comes with some overhead that may not be worth it if you're concerned about performance.

Link: http://dunglas.fr/2015/06/using-psr-7-in-symfony/