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

What is the difference between a framework and a library?
Dec 30, 2015 @ 11:34:10

On Reddit.com's /r/php subreddit there's a discussion that's started up around this video that proposes some of the differences between a framework and a library.

Many people have asked me this question before. It's sometimes hard to get a straight answer, but if we remove all of moot details, use cases, and focus simply on the architectural design details the difference becomes quite clear. This video attempts to explain this difference in a relatively simple and straight-forward manner.

The conversation doesn't just talk about PHP frameworks specifically. There's also some mention of things like jQuery from other programming communities. There's plenty of suggested definitions in the conversation but most revolve around two ideas: that the library is a "tool" to use when needed and the framework is the structure of the application (hence "framework") that "uses you".

tagged: framework library difference video youtube discussion

Link: https://www.reddit.com/r/PHP/comments/3yei0q/what_is_the_difference_between_a_framework_and_a/

May 2014 Issue Released - Making a Difference
May 20, 2014 @ 12:20:43

php[architect] has announced the release of the latest edition of their magazine, the May 2014 edition: "Making a Difference".

Our May issue is now available. While it’s easy to focus on our own needs and tasks, in this issue, we look at how you Make a Difference and bank some karma too.

Articles in this issue include:

  • Joe Devon covering Global Accessibility Awareness Day
  • Michael Crumm on working with Guzzle and APIs
  • Aaron Saray looking at filter_var and other built-in functions
  • Matthew Setter finishes up his Phalcon introduction

You can pick up your copy of this month's magazine either as a single issue or as a part of a yearly (print or PDF...or both!) subscription.

tagged: phparchitect may2014 issue release make difference

Link: http://www.phparch.com/2014/05/may-2014-phparchitect-magazine-released-making-a-difference/

Konstantin Kudryashov:
Conceptual difference between Mockery and Prophecy
Jan 14, 2014 @ 10:47:20

In a new post to his site today Konstantin Kudryashov takes a look at two PHP testing tools and the differences/similarities between them - Mockery and Prophecy. Mockery is a mocking tool created by Pádraic Brady to make mocking simpler and Prophecy is more of a mocking framework, both for use in PHP unit testing.

Today I’ve been asked twice what’s the difference between Mockery and Prophecy just to suddenly discover that I didn’t clarify this aspect never before. Well, that’s about time. If we were to remove all the syntactical and implementation differences between two libraries what we’ll be left with is one really big conceptual difference and it’s the fact that in contradiction to Mockery, Prophecy puts messaging (aka how objects communicate) before structure (aka when objects communicate).

He starts with a sample class (the usual "calculator" example) and shows how it would look to mock it out with each tool, setting return values for both the "getRating" and "setRating" methods. He enhances the tests a bit more to include an event dispatcher and raising an event. The approach is similar, but Prophecy uses something called "message binding" to more effectively handle changes to the class under test.

tagged: difference mockery prophecy unittest mocking framework

Link: http://everzet.com/post/72910908762/conceptual-difference-between-mockery-and-prophecy

Paul Jones:
The Difference Between Factories, Registries, and Service Locators
Dec 03, 2013 @ 10:55:09

In his past few posts Paul Jones has been looking at dependency injection versus service locators. In this new post he continues on the topic comparing three methods for working with objects - factories, registries and service locators.

In last week’s episode of this unexpected series, I said, “Go ahead and use Service Locator, but make sure each Locator contains only one type of object. This condition of restraint will keep a single locator from becoming a menace.” [...] The “only one type of object” constraint generated some discussion regarding factories and registries. [...] The differences between factories, registries, and containers (both service locators and dependency injection containers) can be subtle and hard to grasp at first. Here’s how I keep them straight.

He breaks them down with a simple definition for each related to how the object is created and its intended purpose. He also includes an example of a service locator he's created and a snippet of example code showing it in use.

Again, I must stress: Service locators can easily get out of control. If you can avoid using a service locator, you should.
tagged: factory servicelocator registry difference example code

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

Derick Rethans:
ISO 8601 week dates
Sep 24, 2013 @ 09:54:31

Derick Rethans has a new post with details about handling ISO 8601 dates in PHP via the DateTime functionality. It's a response to some bugs filed having to do with week numbering.

Week numbers are defined in this same ISO 8601 standard. Each year has 52 or 53 weeks and weeks always start on a Monday. Week number 1 of each year is the first week in a year that has the first Thursday of the year, or in other words, the week containing January 4th.

He talks about some of the date format arguments that use would use when working with the ISO 8601 formatting and how it relates to the calendar year. He points out that the "Y" format specifier is not the same as the "o" - the first being the calendar year while the second relates to the ISO 8601 year.

As conclusion, this article shows that there are two ways representing dates in PHP. In the Gregorian1 calendar with year, month and day (of month), and in the ISO 8601 calendar with year, week and day (of week). The format characters for the two different years are either Y or o and they should not be confused.
tagged: iso8601 date datetime format specifier gregorian calendar difference

Link: http://derickrethans.nl/iso-8601-weeks.html

Pádraic Brady:
Stateful vs Stateless CSRF Defences: Know The Difference
Aug 13, 2013 @ 09:49:00

In this new post to his site, Pádraic Brady looks at two methods for generating CSRF (cross-site request forgery) tokens to help protect your application. It's not a tutorial, per se...more of a comparison of two methods: stateful and stateless CSRF tokens.

The difference between Stateful and Stateless CSRF defences is that the former requires storing the CSRF token on the server (i.e. session data) while the latter does not, i.e. the server has zero record of any CSRF tokens. As far as the server is concerned, the number of parties with persistent knowledge of a valid token is reduced to just one – the client. [...] Let’s compare both types of CSRF protections.

He introduces the concepts behind both types of token generation, pointing out that most of the PHP frameworks out there rely on the stateful option (the "synchronizer" method). The other method ("double submit") actually involves two tokens, one in the POST content and the other as a cookie value. He also dissects this other stateless concept article he found and how its method of generation may not be ideal.

Like most attacks, CSRF does not exist in isolation so developing a good defence requires mitigating other attacks. [...] Any good CSRF token implementation, whether stateful or stateless, should reflect those requirements with features for limiting tokens by scope and time.
tagged: csrf token stateless stateful difference doublesubmit random synchronizer

Link: http://blog.astrumfutura.com/2013/08/stateful-vs-stateless-csrf-defences-know-the-difference

Lorna Mitchell's Blog:
Proof that PHP 5.4 is Twice as Fast as PHP 5.3
Jun 14, 2012 @ 10:04:55

In this quick post to her blog, Lorna Mitchell shares an interesting bit of benchmarking she did between PHP versions 5.3 and 5.4, finding 5.4 twice as fast as it's previous version sibling.

So recently I was working on some benchmarks for different versions of PHP, because I heard that PHP 5.4 is "faster" and since I'm a data geek I want to know how much faster! Now, PHP 5.4 is, in general, faster than PHP 5.3 but not twice as fast* unless you pick a use case which has been particularly optimised. My first attempt at benchmarking the two versions produced this. This was a surprise to me; was PHP 5.4 really so much faster??

Her benchmark was a pretty simple one - looping and creating a new object, evaluating the timing of how long it took to execute. A commentor also points to some more official benchmarks that were done and posted to the php.internals mailing list.

tagged: speed version difference improvement create object benchmark


Chris Hartjes' Blog:
DIC vs. Service Locator
Jun 07, 2012 @ 10:09:36

In a new post to his blog, Chris Hartjes shares one thing that you can use to make your code easier to test - using a dependency injection container and how it compares to a service locator.

People often ask me what’s the one thing they could do for their code base RIGHT NOW that will make it easier to test. To me, the answer is simple: make sure you are using Dependency Injection (yes the link is long and has code samples in Java, but whatever). Without the ability to “inject” your dependencies into your code (whether it is class methods or functions) you will have problems testing modules of code in isolation from each other.

He shows the possible uses of DICs, including code samples, and talks the differences between the two. He explains that the real difference in them is how its being used. When it's used to add and remove instances, it's a container. When its actually put to use and passed into a class, it morphs into a service locator.

tagged: dependencyinjection servicelocator testing difference


Lorna Mitchell's Blog:
Accessing the Magento V2 API
Jun 24, 2010 @ 11:44:18

Lorna Mitchell has a new post to her blog today looking at one of the differences she's found in her work with the Magento API between version 1 and version 2.

I must say that I am always pleased when I see that these products do include some kind of API. The Magento one is a bit interesting, although there is some half-decent API documentation for the original API. However they have then released a new version of the API, with very little documentation.

Her example code shows the difference in a call to grab a customer list from the SOAP interface - the version 1 method used a "customer.list" request while the version 2 method just made use of a normal SOAP method call to the "customerCustomerList" method on the service.

tagged: magento version difference api soap


Alan Sorkin's Blog:
The Difference Between A Developer, A Programmer And A Computer Scientist
Mar 16, 2010 @ 08:08:45

On his blog today Alan Sorkin has a humorous take on what the difference is between computer scientists, programmers and developers according to where they place their focus.

I have often used those three terms almost interchangeably, yes, even computer scientist. After all, most of us have a degree in computer science, so what does that make us? However, recently I find that those three things have come to take on more and more distinct personalities in my mind. [...] It is difficult to define what each one should be, (it is more of a gut feel rather than a strict delineation) they are very similar (and rightly so), but I am going to attempt to do it anyway.

He splits them up according to a few criteria - how their code looks, how it works and what level their math skills are at. The photos he uses to further define each are pretty dead on too.

tagged: opinion difference computer scientist programmer developer