Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Zsolt Szend:
Dynamic dependency injection
May 18, 2016 @ 18:32:25

In this new tutorial Zsolt Szende talks about dependency injection and how to handle objects and related needs at runtime rather than the pre-configured method that some injection containers/systems have defined.

In this short article I would like to demonstrate a way to inject dependencies that are not known until runtime. There are many use cases for this and in essence it is about choosing between concrete implementations of some common interface. In object oriented design this is known at the Strategy pattern. The choice itself can be made in various ways, for example via a configuration option or a command line parameter in case of a console command, and I think the dynamic nature of the choice is the most interesting part of the pattern.

The article provides a practical example of an XML/JSON reader pulling information from an external source. A simple interface is defined and two implementation classes put it to use. Then the "command" pattern is used to apply it to an executable script and how injecting a reader type directly overrides the one from the provided option. This is taken a step further and refactored into a "resolver" to determine the best logic to apply based on the input argument.

tagged: dynamic dependency injection xml json reader tutorial resolver

Link: http://pwm.github.io/dynamic-dependency-injection/

SitePoint PHP Blog:
We’re Building a Marvel Catalog Reader! Avengers, Assemble!
May 16, 2016 @ 18:23:08

On the SitePoint PHP blog they've shared a tutorial covering the construction of a Marvel Catalog Reader that hooks in to the Marvel API for its data.

In this tutorial, we’re going to take a look at the Marvel API, a tool provided by Marvel for developers to get access to the 70-plus years of Marvel comics data. First, we’ll walk through the steps in which one can acquire the keys needed to make requests to the API. Then, we’ll look at the tools we can use to test out the API. Finally, we’re going to build a website that uses the API.

They start out on the API side of things, showing you how to sign up for an account, get your token information and include a note about using the API (rate limiting and referencing the source of the images). There's a mention and example of working with the interactive API documentation and the first part of the code you'll need to make the connection. They then get into the construction of the site itself using the Laravel framework and a simple caching command. This is used to store the results from a query made via a Guzzle client. The focus then shifts to the frontend where they create the HomeController and define both the main endpoint and two others: one for viewing a specific comic and the other for the character listing. The tutorial continues on showing you how to handle the (paginated) responses from each of the calls and push the results into a cache record. Finally, they create the matching views of the API query results and some example screenshots of the results.

tagged: marvel api tutorial laravel frontend cache reader guzzle

Link: http://www.sitepoint.com/were-building-a-marvel-catalog-reader-avengers-assemble/

SitePoint PHP Blog:
Building a Hacker News Reader with Lumen
Mar 01, 2016 @ 16:40:41

The SitePoint PHP blog has posted a tutorial from author Wern Ancheta showing you how to use Lumen to make a simple news reader specifically for the content of the Hacker News website via their API.

In this tutorial, we’re going to build a reader for Hacker News. We will be using the Hacker News API and the Lumen framework to implement this.

The end result basically lists the top stories from the front page along with the current number of upvotes they've received. He first walks you through the process to get a new Lumen-based application up and running. The tutorial then helps you get a database set up to locally store the data (so it's not hitting the API every time) and add in the two basic routes. It then shows how to make use of the task scheduler functionality to create and perform the requests to the Hacker News API and fetching the latest items to store in the database. Full code is included to create the Guzzle HTTP client instance to make the requests and parse the results. Finally, he shows the creation of the index and news output pages including the controller, views and CSS to style the markup output nicely.

tagged: hackernews api news reader lumen laravel tutorial guzzle

Link: http://www.sitepoint.com/building-a-hacker-news-reader-with-lumen/

Mathias Noback:
Some questions about the command bus
Jan 12, 2015 @ 15:46:46

Mathias Noback has continued his series looking at the use of command busses in PHP applications. In this third part of his series, he answers some questions that have been asked by his own readers.

So far we've had three posts in this series about commands, events and their corresponding buses and handlers: a wave of command buses, responsibilities of the command bus, from commands to events. Now I'd like to take the time to answer some of the very interesting questions that by readers.

He answers questions about:

  • The difference between commands and events
  • Disadvantages of using a command bus
  • The command as constructor argument
  • How to return a value from the command bus
  • Could commands handle themselves?

Each question comes with a portion of the question from the original author, an explanation and some code where needed to illustrate his point.

tagged: commandbus question answer reader events disadvantages return handling

Link: http://php-and-symfony.matthiasnoback.nl/2015/01/some-questions-about-the-command-bus/

PHPMaster.com:
Consuming Feeds with SimplePie
Apr 22, 2013 @ 16:47:50

In a recent post to PHPMaster.com Kevin Mowry shows you how to use SimplePie, a simple to use programatic feed reader you can use to parse things like RSS feeds.

If you’re an avid feed consumer like I am, you might be a bit sad to see Google’s recent announcement of Reader reaching end of life. Reader was simple and easy to use, but there’s no reason you can’t have the same functionality with your own homegrown project. The PHP library SimplePie allows for quick and easy feed consumption and display. Here’s how you can get started on your own feed reader.

He helps you get it installed (via Composer) and shows you how to use some of its most basic functionality to parse the New York Times' feed. He also includes examples of getting the information back out of the SimplePie object. There's also some snippets that show how to only get the latest items and how to cache the results.

tagged: simplepie rss feed reader tutorial nytimes

Link: http://phpmaster.com/consuming-feeds-with-simplepie

Cal Evans' Blog:
5 PHP twitter accounts that have replaced my feed reader
Aug 12, 2010 @ 17:07:29

In a new post to his blog Cal Evans has posted five twitter accounts that he's used to replace his feed reader for everyday reading:

I have given up on feed readers. I never did like them much to begin with and have found over the past couple of years that twitter does a better job of showing me interesting blog posts than Google Reader ever did. In addition to recommendations from friends however, there are a hand full of accounts that I follow to keep up with what is going on.

Here's his list of the five accounts to follow:

tagged: blog twitter feed reader opinion

Link:

Marco Tabini's Blog:
It turns out, I was wrong
Dec 01, 2008 @ 13:54:29

Correcting himself from some previous comments concerning PHP 5 versus PHP 4 usage among developers, Marco Tabini has posted something new to his blog with some updated stats.

In the past, I have not been shy about sharing my opinion that the impending death of PHP 4 would have wreaked all sorts of havoc over the PHP world. I am glad to say that I've been wrong - dead wrong, in fact - and that I have never been as happy to be so far off the mark before.

According to a readers survey that the php|architect magazine ran (about a year ago even) PHP 5 is stronger than ever, taking up well over sixty percent of the usage with only a small part still hanging with PHP 4. Check out his graph for the full rankings.

tagged: statistics php4 php5 usage correction phparchitect survey reader

Link:

CSS Tricks:
Create a Slick iPhone/Mobile Interface from any RSS Feed
Jul 17, 2008 @ 15:22:55

On the CSS Tricks blog there's a recent article showing how to combine the jQuery Javascript library and the SimplePie PHP feed aggregator to create a iPhone/mobile interface to any RSS feed.

We are going to create a web page that is formatted specifically for the iPhone (but would presumably be good for other mobile devices as well). This web page will dynamically fill itself with content from any RSS feed that you give it. The interface is going to be built to be easy to use on a mobile device, with large "touchable" areas and nice (jQuery) animations that whisk you between articles.

They work through the process - five simple steps:

  • Create the iPhone Environment
  • Pull in the RSS Feed
  • Creating the Front Page: Headlines Only
  • Creating the Article Pages: jQuery Slider Style
  • Adding Some Flair

All code and images needed are included (as well as a demo if you'd like to try it out).

tagged: iphone tutorial mobile rss feed reader simplepie jquery

Link:

Doug Hill's Blog:
PHP Weekly Reader - May 16th 2008
Mar 17, 2008 @ 14:35:52

Doug Hill has decided to start a series on his blog that details some of the happenings in the PHP community for the past week, of which this is the first:

I spend way too much time reading blogs, surfing PHP and web development articles online. I resolve to cut back but things just sneak back into my reader somehow, and believe me dzone doesn't help. But I've came up with a way to justify all that time, I call it research.

He mentions things like the infamous CIO article, Zend's Jolt Award, comparing the Zend Framework versus PEAR and PHP releases, books and various other language-related tidbits.

Check out the post for more and keep an eye on Doug's blog for future weekly summaries.

tagged: weekly reader summary article news trends

Link:

ProDevTips.com:
Ajax, ZF and Smarty feed reader: part 3
Nov 19, 2007 @ 17:19:00

ProDevTips.com has posted the thier part of their series looking at building a feed reader with Ajax, the Zend Framework and Smarty (see parts one and two here).

This time we will take a look at the feed list window and the manage window. This will also be the concluding part of the series.

All of the code is provided (a full download is here for all three parts) and they gloss over a lot of the code assuming you know something about reading it - including a lot of the HTML for the presentation.

tagged: prodevtips ajax zendframework smarty feed reader prodevtips ajax zendframework smarty feed reader

Link:


Trending Topics: