User Authentication in Laravel 4.x: Simple Guide Part 2

Part 1: User Authentication in Laravel 4.x: Simple Guide Part 1

user authentication in laravel 4 part 2
User Authentication In Laravel Screenshot

Let’s see what we have covered so far in the first part of this tutorial:

  • Database Creation And Configuration
  • Migrations
  • Seeding
  • Controllers

Now we are left with Routing and Views, let’s start with routes first.

Defining Routes

Since we are using restful controllers in our application, we will be using Route::controller() method for registering routes. Route::controller() allows us to define all the routes to a restful controller’s actions using a single call per controller. Continue reading User Authentication in Laravel 4.x: Simple Guide Part 2

User Authentication in Laravel 4.x: Simple Guide Part 1

user authentication in laravel 4 part 1
User Authentication In Laravel 4 Tutorial

In my previous article regarding Laravel migrations, I have mentioned that Laravel has a nice Authentication component. Today, we will see how we can use Laravel’s Auth component to build a simple user authentication in Laravel 4. So, let’s get started. Continue reading User Authentication in Laravel 4.x: Simple Guide Part 1

Database Migrations In Laravel 4

Laravel 4 developed by Taylor Otwell, is indeed a great php framework out there. It is suitable for both small and large scale applications, and has a very active community of really helpful people. I started using laravel more or less four months ago, and I have not searched google for “the best php framework” since then. With its powerful components like: a powerful and flexible routing system, an expressive query builder Fluent, Eloquent ORM, a descent authentication component, an intelligent IoC Container, Blade template engine and Artisan CLI tool, it just rocks (pardon me if I am missing something here).

Database Migrations In Laravel

Database migrations in Laravel provide you with an easy way of managing your application’s database schema. When using migrations, a lot of tasks related to database schema become a lot easier; by using migrations you can change the structure of database tables on the fly Continue reading Database Migrations In Laravel 4

Managing Dependencies Using Inversion Of Control in PHP: Step By Step

In my previous article, I have explained DI (Dependency Injection). In this article, I will explain how we can use Inversion of Control in PHP to reduce complexity that comes with DI.

Every design pattern has its positive and negative aspects, DI can make it easier to automate the testing process using unit testing frameworks. But, on the other side, DI can introduce extra complexity in your code that makes it more verbose and less readable. For example:


$subdep = new SubDep();     //dependency required for Dep1 class.
$dep1 = new Dep1($subdep);  //creating Dep1 by injecting its dependency
$dep2 = new Dep2();         //creating Dep2.
$dep3 = new Dep3();         //creating Dep3
$instance = new SomeClass($dep1,$dep2,$dep3); // injecting required dependencies

As you can see, SomeClass requires three dependencies, whereas Dep1 has its own dependency (more complexity). So the point is, if you are dealing with lot of dependencies in your application, you could end up writing and repeating a lot of code throughout your application. To subdue this problem, we use another design pattern called as Inversion of Control Container.

In software engineering, inversion of control (IoC) is a programming technique, expressed here in terms of object-oriented programming, in which object coupling is bound at run time by an assembler object and is typically not known at compile time using static analysis.

Inversion Of Control in PHP: Dependency Management

What I have learned so far is, the more you try to explain inversion of control, the more it gets complicated. So, instead of digging in further details, its better to work through an example. Continue reading Managing Dependencies Using Inversion Of Control in PHP: Step By Step

Dependency Injection In PHP: Made Easy

In object oriented programming, tightly coupled objects / classes often result in an untestable, and a difficult to manage code base. These tightly coupled classes can be re-factored, and coupling can be achieved through DI (Dependency Injection). The principle of decoupling is based on the fact that, every object should be assigned one and only one responsibility, and there is no need for one class to be aware of the other.

Single Responsibility Principle:
In object-oriented programming, the single responsibility principle states that every class should have a single responsibility, and that responsibility should be entirely encapsulated by the class. All its services should be narrowly aligned with that responsibility.

Separation Of Concerns:
In computer science, separation of concerns (SoC) is a design principle for separating a computer program into distinct sections, such that each section addresses a separate concern. A concern is a set of information that affects the code of a computer program. A concern can be as general as the details of the hardware the code is being optimized for, or as specific as the name of a class to instantiate.

Consider the following Product class which uses a database to store and retrieve products Continue reading Dependency Injection In PHP: Made Easy