Benefits of using custom exceptions in PHP

Exceptions are really useful when you want to handle some situations which can not be handled gracefully otherwise. So, using exceptions, you can handle certain sceanrios by showing a nice error message. Take the following example for instance.

» Read More

Using arrow functions in PHP 7.4

When PHP 7.4 released, it came with a whole lot of features/improvements that makes the language more interesting to work with. The one such feature that I want to talk about is arrow functions. For a primer, arrow functions are not new. In fact, If you’ve been working with the latest JavaScript (EcmaScript 6), you might’ve worked with arrow functions already.

» Read More

Constructor property promotion could be coming to PHP

Have you ever felt the class properties that you’re using in the constructor are essentially repeated multiple times? i.e At the declaration, in the constructor parameters and while doing assignment in the constructor. For instance, take the following example.

» Read More

Customizable artisan stubs in Laravel 7

Artisan commands in Laravel are truly a blessing. I mean you could create just about any files be it controllers, models, middleware, provider by knocking a simple command from the CLI. For instance, if you want to create a model named Post you could just fire the following command…

» Read More

Fluent string operations in Laravel 7

Laravel 7 has been a major version that’s been released last week and it comes with the host of features and improvements to the Laravel framework. One of the improvements being the new fluent string operations API. The goal of these API is to provide more flexibility and readablity to the regular string operations in Laravel by chaining array of string manipulation methods.

» Read More

Computed properties and methods in PHP

Sometimes, it’s handy if we have an ability to create property and method names from another properties just like what we have in JavaScript. In another words, a property or method name which can be set and used dynamically. For instance, a normal property can be set with a statement in PHP like so.

» Read More


Follow me on Twitter as @amit_merchant