Adapter pattern in php

Can we Adapt SMS into MAIL?
Now we’re going to do an impossible task.
Are you prepared?
Can we start?
This chapter is about the adapter pattern. It’s one of the design patterns that you’re currently on. Let us start with a real world example.
You know that internet connection is absolutely necessary for sending emails. Is it true in the real world? You’d say, well, I know that. An internet networking is a must.

Continue reading “Adapter pattern in php”


Chain of responsibility design pattern in php

Let us see how Responsibility can be Unchained!
In object-oriented design, the chain-of-responsibility pattern belongs to behavioral design patterns segment. The simplest example contains a person using ATM. He’s entering pin, receiving payment and receipts etcetera.
What is behavioral design pattern? They are a type of design patterns that generally identify communicating objects.
You may ask, what kind of objects we’re talking about? These objects have common communication patterns between them. While communicating they must realize that patterns.

Continue reading “Chain of responsibility design pattern in php”

Decorator Pattern in PHP

When we want to add additional features to our existing classes we generally use decorator pattern.
Do you find this definition useful?
I believe the answer will be NO.
It says about only adding new features. It doesn’t say about how you will use that. Will you add the features by simply hard coding or you’ll add them in the run time.
That’s a pretty big difference.
Let us consider a simple example where we are talking about a hosting company. A typical hosting company sells hosting services and sometimes they also provide template designing.
Let’s design a pretty basic scenario.

Continue reading “Decorator Pattern in PHP”

Forms in Laravel 5.3

To fill up the forms, you need to feel the forms first. Since laravel 5.2.45 this feeling is little bit different. It’s become little bit tricky.
You need to install HTML form builder so that you can use laravel form blade template and it’s really important for security reasons. But, there is a seize. Since laravel 5.2.45 the old trick will not work. You can no longer use ‘composer require illuminate/html’ command to add form builder templates to your project. Instead, you have to issue this command:

sudo composer require laravelcollective/html

It’ll take few minutes for composer to update your system. Next it’ll search for ‘providers’ and ‘aliases’. So you must open ‘Code/test/blog/config/app.php’ file and this line inside ‘providers’ array.

'providers' => [

         * Laravel Framework Service Providers...

Continue reading “Forms in Laravel 5.3”

Routing in Laravel 5.3

Routing, a Static Method

Routing is the concept of setting up a new URI like http://localhost:8000/hello. It will take you to a destination web page. Laravel makes it extremely simple. It’s a static method that accepts two things: an URI and an anonymous function or Closure.
In the ‘app/Http/routes.php’ it’s been defined primarily. Start your favorite text editor and open the file. What you see?
You see some code like this:

Route::get('/', function () {
return view('welcome');

Continue reading “Routing in Laravel 5.3”

Composer Revolution in PHP

Composer is a dependency management tool in PHP. For any PHP project you need to use your library of codes. Composer easily manages that task on your behalf helping you to declare those codes. You can also install or update any code in your library through composer. Please visit for more details.
In the opening page of, click the ‘getting started’ link.

composer home page

composer home page

In the above page you find two links – ‘locally’ and ‘globally’. It stands for two options. Suppose you don’t want to run composer globally or centrally in your system. In that case, you have to download and install composer each time for every project. But the global option is always preferable because once composer is installed in your system bin folder you can call it any time for any project.

Continue reading “Composer Revolution in PHP”

Environment in Laravel 5.3

Laravel comes with many stunning features. One of them is definitely database migrations. In the next chapter we’ll discuss about migration in detail.
Before that we need to understand our environment properly. What is environment in Laravel? If you look at the document root you will find an ‘.env’ file. It basically says about the database connections. Where would we get that default database set up file? In the ‘config’ folder, we have a ‘database.php’ file. Open it up and see the content.

Continue reading “Environment in Laravel 5.3”