Monthly Archives: October 2016

Decorator Pattern in PHP

Standard

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

Read the rest of this entry

Advertisements

Forms in Laravel 5.3

Standard

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.


//Code/test/blog/config/app.php
'providers' => [

        /*
         * Laravel Framework Service Providers...
         */
        …
        'Collective\Html\HtmlServiceProvider',
…
        ],

Read the rest of this entry

Routing in Laravel 5.3

Standard

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');
});

Read the rest of this entry

Composer Revolution in PHP

Standard

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 https://getcomposer.org for more details.
In the opening page of https://getcomposer.org, 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.

Read the rest of this entry

Environment in Laravel 5.3

Standard

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.

Read the rest of this entry

A humble approach to my books…

Standard

First, it was a mail from Pramila Balan, the acquisition editor of Apress. They wanted to publish my book on ethical hacking.
After a few more conversations they finally decided to publish two books – another one about Laravel that has been in the market nearly for a year or more.
My Books in Apress
I saw the whole development as a warning from my creator, probably the last warning; that simply says: grow up, life is too short and there are so many things to do.