Interfaces are one of the main features of object-oriented languages, they provide polymorphic behavior and are the base of highly extended patterns and techniques like the Repository Pattern and Dependency Injection, but do they really make sense in PHP? Let’s dig into this.
First of all, I want to say interfaces are one of my favorite features in an object-oriented programming language, and PHP is not the exception, I love interfaces, and I’m not trying by any means to dismiss its usage, but the opposite! …
Before starting the post I would like to say I’m not a “design patterns guru” or something like that. I’m just a passionate developer who loves clean code and elegant solutions, I come across a lot of issues every day and looking for solutions to share with the community is my way to deal with it. If you think my approach is not the best to deal with null return types or want to add something to my post, you can reach me on Twitter and I will be happy to start a polite discussion with you.
The problem: many…
The obvious answer when you want to build a demo application is a todo list.
Before starting there are certain tools you need to install.
Install the .NET Core SDK, we will be using version 2.1.
Download and install Visual Studio Code.
Install the C# extension. If you want to set up a better workspace for…
Note: most of the concepts exposed in here can also be applied in the Laravel framework.
Testing commands can be a pretty straightforward task or a total headache. Let’s see why.
Laravel provides an easy way to test your commands as you can see in the following example extracted from the official documentation.
public function test_console_command()
->expectsQuestion('What is your name?', 'Taylor Otwell')…
We have been using the mixed keyword for years into our PHP docblocks to specify that a value can be, well, kinda “mixed”. With the addition of scalar and return type declarations in PHP 7.0, and the subsequent improvements (nullable and void types in PHP 7.1 and object pseudo-type in PHP 7.2) many people may think that a mixed type is not necessary, but I think that now more than ever it is.
People may say that if you depend on a “mixed” type then your design is bad, after all, if you need an integer, why to expect a…
PHPCollections is a set of Java/C#-like collections written in PHP, the idea behind this is to have a similar way of dealing with large and complex amounts of data in a powerful way with a simple API instead of working with plain PHP arrays.
I started this project about a year ago (the first commit date is 10/10/2017!), and for whatever reason I never found the time to complete it, until now of course.
Maybe you’re thinking right now “why work with collections?”, “What is the big deal?”, “We have beautiful native arrays!”, …