Tuesday 27 May 2014

URL Shortner Application in Laravel

Hello friends today we will create a url shortner application in Laravel 4, where will will use the get,post Http verbs to show the form on load and to process the form.

First of all you have to install laravel through composer if you already have laravel install you are good to go otherwise do install it first.

First Create a database call it laravelurlshortner (or any name you like.)  and in your app/config/database change the database name you have just created in database.

Now create a migration for your database to create tables,don't worry guys if you don't know how to create a migration i will look after that..

First go you your terminal (cmd) and go the exact url like below image and copy


 and in your termnal chnage the path by just typing cd then what you have copied and press enter
and type :- php artisan migrate:make create_links_table -- create

And go the app/database/migrations and you will notice  your migration is generated.

open it in your editor

and replace it with this code---

<?php

use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateLinksTable extends Migration {

/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('links',function($t){

$t->increments('id');
$t->text('url');
$t->string('hash',400);
});
}

/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('links');
}

}

------------------------------------------------------------------------------------------------

Now again open your terminal and type:- php artisan migrate

And now visit your database and you will notice that your link tables has been created.

--------------------------------------------------------------------------------------------------

You can download the full code from  --- http://www.mediafire.com/download/1677raomrhq9a2n/laravelurlshortner.rar

Just download the code and look into the controllers and routes and models section..

Thank You...

No comments:

Post a Comment

Thank your for your comment..your submitted coment will be live after admin approval