Category: php

The adapter pattern also referred as the wrapper pattern, I find that wrapper is a more fitting name since it describes clearly what this pattern does; it encapsulates the functionality of a class or object into a class with a common public interfaces.

In software engineering, the adapter pattern...

Now that Magento2 beta has been officially released, you are probably wondering what the hell are Service Contracts and more importantly why the hell do you need them.

But before we jump into the nitty-gritty of service contracts let's get this out of the way:

If you have been working with PHP for a while, chances are that you have come across with a project, extension or script that requires to be tested on multiple PHP versions, for simple CLI scripts this seems easy enough but what happens when you are working with complex applications,...

I previously mentioned Boris, a terrific REPL for PHP, and while Boris is a great and functional REPL, is not the only available.

Psysh is actually more than a simple REPL it's also an interactive debugger; which means you can say goodbye to the endless barrage of var_dump() and die()...

Recently Facebook unveiled Hack, a new programming language that aims to provide developers with the tools to write and ship code quickly while catching errors on the fly.

What is Hack?

Hack is as programming language designed to work with HHVM and the same time it works seamlessly with PHP...

Among the new features and fixes that come with PHP5.4 we have the addition of traits to the PHP language, PHP is a single inheritance language this means that classes and only inheriting from single parent class, in practice this complicates code organization and can lead to code duplicity.

Languages...

REPL(read-eval-print loop) can be great tools for quickly testing concepts, experimenting and getting quick feedback when learning a new language. Many languages and frameworks provide some sort of REPL like the rails console or laravel's artisan tinker.

PHP by itself has the interactive shell that can be invoked with:

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...

The factory pattern is one of the most commonly used Design Patterns, it is useful when we need to choose between several interchangeable classes at runtime. By using factories we are also separating the creation of an object from the actual implementation.

We can define a factory as a simple...

Dependency Injection is a software design pattern that allows avoiding hard-coding dependencies and makes possible to change the dependencies both at runtime and compile time.

By using Dependency Injection we can write more maintainable, testable, and modular code. All projects have dependencies. The larger the project the more dependencies is...