News Feed
Sections




News Archive
feed this:

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

Qafoo Blog:
Utilize Dynamic Dispatch
October 16, 2014 @ 11:52:18

On the Qafoo blog today Tobias Schlitt talks about dynamic dispatch, what he calls a "fundamental concept of OOP" to help provide clean, clear interfaces in the code.

I want to use this blog post to illustrate the concept of dynamic dispatch which I use a lot recently to motivate creating clean OO structures in my trainings. In my experience, this helps people to understand why we want to write code in this way. After that I will show why traits are bad in this direction.

He explains the concept of "dynamic dispatch" by starting from the beginning...with procedural PHP code. He looks at the usual flow of this kind of application that call shared functions in a "top down" fashion. He looks at what would happen if new logging needs were introduced (use a new method? patch the current one?) and the dependencies that can be introduced because of it. With this in mind, he continues and talks about how the "dynamic dispatch" happens during the code execution, splitting the log request based on the information it's given instead of different implementations for each. He points out that using a trait doesn't allow for this abstraction and instead embeds the code into the class itself, re-introducing the original problem.

0 comments voice your opinion now!
dynamic dispatch oop concept example logger trait compare

Link: http://qafoo.com/blog/072_utilize_dynamic_dispatch.html

Phil Sturgeon:
What is The League of Extraordinary Packages?
October 16, 2014 @ 10:48:29

In his latest post Phil Sturgeon talks about a project that's been running for a while, the The League of Extraordinary Packages and aims to clear up some recent misconceptions about the group and what they strive for in the projects they endorse.

This is the story of group of friends, who decided to write some code, but somehow confused and angered everyone with a keyboard. [...] Where should I release this code [I was super excited about releasing]? Should I release it with a vendor name of Sturgeon? That seemed rather egotistical. I could make something up, but what is the point of a single vendor with a single package? I wondered if any of my buddies were having this problem. [...] Being as hungover as I was, I thought long and hard, for about 5 seconds until something amazing happened in my brain... The PHP Super Best Friends Club! The guys loved it, and we started making plans immediately.

He goes on to talk about The League and some of the goals of the organization including the stated desire for quality code and a constant stream of work on the project (no abandoned or stale projects). He talks about how some of the rules for inclusion were created and some of the members of the various projects it includes. He then gets to the "recent misunderstanding" part of things with the clash of the League and the PHP-FIG (see here). He clears up some of the confusion in that thread by stating that:

  • League != PHPClasses
  • League != PEAR

He finishes off the post talking some about the leadership of the group (hint: it's an organization, not really run by a person or persons) and some of the work he's doing to ensure the future of the League and the packages it includes.

0 comments voice your opinion now!
league extraordinary packages phpclasses pear compare rules community

Link: https://philsturgeon.uk/blog/2014/10/what-is-the-league-of-extraordinary-packages

Dave Marshall:
Mockery Spies
October 09, 2014 @ 10:29:08

In his latest post Dave Marshall takes a look at a handy feature of the Mockery mocking tool (helpful for unit testing) and how to use them in your testing.

Spies have been on the cards for mockery for a long time and even after putting together an implementation in February, I kind of stalled out on making a decision on the public API. Fast forward a few months and I figured it was just time to ship it, so I went with the most mockery like API and merged it in. Mockery still doesn't have a 1.0 release, so I can always make changes before we go 1.0.

For those not familiar with the concept of "spies" in testing he includes a brief definition and some of the reasoning behind using them. The first is relatively simple: how they can reveal the intent of the test. They also allow for two other types of testing methods, "Arrange-Act-Assert" or "Given-When-Then" thinking patterns. He does mention, however, some of the problems with using spies over mocks (including that they're less precise, possibly leading to looser testing). He finishes up the post with a quick note about partial spies and how they can provide a nice compromise in your testing.

0 comments voice your opinion now!
mockery unittest spies doubles mock compare feature

Link: http://davedevelopment.co.uk/2014/10/09/mockery-spies.html

Kinsta.com:
Real-World WordPress Benchmarks with PHP5.5 PHP5.6 PHP-NG and HHVM
July 30, 2014 @ 12:26:51

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.

0 comments voice your opinion now!
wordpress benchmark php55 php56 phpng hhvm compare results

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

Stephan Hochdörfer:
Controller classes vs. Action classes
May 19, 2014 @ 10:52:31

In this new post to his site Stephan Hochdörfer covers some of his own thoughts about the recently proposed application structure from Paul Jones, the "Action-Domain-Response" pattern. In this post Stephan compares the typical controller classes with an action class.

First of all I do have the feeling that controller classes make it harder to structure your logic. I have seen a lot of "God Controllers" that do a shitload of stuff. Stuff that is not really related to each other. [...] action classes tend to be rather small, typically less than 100 loc for us. That also helps a lot when trying to understand what`s going on. I am aware that there are developers out there who are afraid when it comes to dealing with a lot of classes. [...] That`s another bonus point for action classes: It is easier to search for a class name than a method name in most IDEs.

He goes on to talk more about "God controller" classes, their dependencies and how that compares to action classes only taking in what they need. He touches on the reusability of action classes as opposed to controllers and how they come in handy for storing common logic.

0 comments voice your opinion now!
controller action class compare logic dependency

Link: http://blog.bitexpert.de/blog/controller-classes-vs.-action-classes

SitePoint PHP Blog:
HHVM vs Zend Engine in PHP 6
January 27, 2014 @ 12:05:55

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.

0 comments voice your opinion now!
hhvm sitepoint pro con compare zendengine

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

SitePoint PHP Blog:
Message Queues Comparing Beanstalkd, IronMQ and Amazon SQS
January 08, 2014 @ 10:37:35

The SitePoint PHP blog has a new post looking at using message queues in PHP. More specifically it compares a few of the different solutions out there and their advantages/disadvantages - Beanstalkd, IronMQ and the Amazon SQS.

This article introduces the concept of message queues and discusses the strengths and weaknesses of three specific message queue services: Beanstalkd, IronMQ and Amazon SQS. [...] Queues allow you to store metadata for processing jobs at a later date. They can aid in the development of SOA (service-oriented architecture) by providing the flexibility to defer tasks to separate processes. When applied correctly, queues can dramatically increase the user experience of a web site by reducing load times.

He starts with some of the overall benefits and downfalls of using a queueing system in your application, including some common use cases. From their he breaks it up into sections, in each talking about the option and how it differs from the others:

  • Services
  • Server setup
  • Service Level Agreements (SLAs)
  • Architecture
  • Client libraries
  • Management interface
  • Redundancy
  • Security
  • Speed
  • Fidelity
  • One-time pickup

...and many, many more. If you're looking for a good, complete overview of how these three options compare on a wide range of features and configurations, definitely check out this post. It even includes some PHP close to the end to make the connections to each and send/receive messages.

0 comments voice your opinion now!
message queue compare beanstalkd ironmq amazonsqs advantage disadvantage tutorial

Link: http://www.sitepoint.com/message-queues-comparing-beanstalkd-ironmq-amazon-sqs/

Aura Blog:
Which is Lighter, Silex or Aura.Web_Project?
December 26, 2013 @ 09:40:01

In a recent post the Aura PHP blog compares the "lightness" of two different micro-framework-oriented packages - Silex and Aura.Web_Project (of the Aura framework project.

Too many people, including the Silex article author, use absolute terms like "light" and "heavy" and "bloated", instead of relative terms like "lighter" and "heavier" and "more bloated" and "less bloated", to describe software. Any time someone uses an absolute term like that, you need to ask: "Compared to what?" [...] don't know if the measurements in that article are valid or useful for defining "what makes a microframework" but they do provide a basis for comparison. I understand that some people think "measuring (size|lines-of-code|number-of-classes) is stupid and it doesn't matter!" Maybe it is, maybe it's not. [...] So, let's go with that article and use its approach to make a comparison between Silex and Aura.Web_Project to see if my earlier claim, using the terms and measurements outlined by the Silex post author, is accurate.

The rest of the post outlines the steps that were taken to perform the measurements, the tools used check things like memory usage and the results. They compare things like:

  • Total Package Dependencies
  • Total Disk Usage
  • Total Class Count
  • "Actual Usage" Class Count
  • "Actual Usage" Non-Comment Lines Of PHP Code
0 comments voice your opinion now!
silex aura framework webproject compare lighter

Link: http://auraphp.com/blog/2013/12/23/lightness-silex-vs-web-project/

Paul Jones:
Quicker, Easier, More Seductive How To Tell A DI Container From A Service Locator
December 17, 2013 @ 13:55:11

Paul Jones has continued his posts about dependency injection containers versus service locators in his site with this new post that hopes to make it easier for you to tell the difference between the two.

It is easy to confuse a Dependency Injection container with a Service Locator. They are very similar to each other. The differences are subtle. Indeed, it's even possible to use a Dependency Injection container as a Service Locator, although I think it's difficult to use a Service Locator as a Dependency Injection container. They are both sub-patterns of a more generic pattern called Inversion of Control, and some people confuse the term Dependency Injection with the more generic term Inversion of Control.

He starts off with a few questions you can ask to see which camp the implementation belongs in, mostly revolving around how the objects are fetched. He includes some code samples to help reinforce the point, showing both a service locator and DIC. He's also done some looking around at some of the major DIC implementations and which of the two he sees them as (with a few notes explaining his thoughts).

0 comments voice your opinion now!
service locator dependency injection compare inversionofcontrol

Link: http://paul-m-jones.com/archives/5843

Phil Sturgeon:
Benchmarking Codswallop NodeJS v PHP
November 12, 2013 @ 09:21:29

Phil Sturgeonhas posted about some Node.js vs PHP benchmarks that someone linked him to concerning web scraping. The article suggests that Node.js "owns" PHP when it comes to this but, as Phil finds out, there's a bit more to the story than that.

Sometimes people link me to articles and ask for my opinions. This one was a real doozy. Oh goody, a framework versus language post. Let's try and chew through this probable linkbait [where] we're benchmarking NodeJS v PHP. Weird, but I'll go along with it. Well, now we're testing cheerio v PhpQuery which is a bit different, but fine, let's go along with it.

Through a little discovery, Phil noticed phpQuery using file_get_contents, a blocking method for fetching the remote pages to scrape. Node.js instead uses a non-blocking method, meaning multiple files can be fetched at the same time. In answer to this blocking vs non-blocking, he decided to run benchamrks against a few cases - Node.js/Cherrio, PHP/phpQuery and his own, more correct comparison to the Node option - PHP/ReactPHP/phpQuery. He's shared his results, showing a major difference between the straight phpQuery and the React-based version.

It seems likely to me that people just assume PHP can't do this stuff, because by default most people arse around PHP with things like MAMP, or on their shitty web-host where is is hard to install things and as such get used to writing PHP without utilizing many extensions. It is probably exactly this which makes people think PHP just can't do something, when it easily can.
0 comments voice your opinion now!
nodejs reactphp webpage scraping benchmark compare

Link: http://philsturgeon.co.uk/blog/2013/11/benchmarking-codswallop-nodejs-v-php


Community Events





Don't see your event here?
Let us know!


series package list podcast release library deployment interview install language laravel framework update introduction tips community api zendserver symfony opinion

All content copyright, 2014 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework