KEMBAR78
Laravel Beginners Tutorial 1 | PPTX
1 Author : Vikas Chauhan
Presented By:
Vikas Chauhan
Software Engineer,
BrainCoerce Technologies, Bangalore
Date – 08/08/2013
2
 Exercise 1 :- Installation and configuration
 Exercise 2 :- Write Hello World Program
 Exercise 3 :- Laravel Blade
 Exercise 4 :- Laravel Blade & Layout
 Exercise 5:- Types of Route
Author : Vikas Chauhan
3
Exercise 1
Installation and configuration
Author : Vikas Chauhan
4
Task 1 :- Install Composer.
- Go to http://getcomposer.org/ and download.
Author : Vikas Chauhan
5
Task 2 :- Install & configure Laravel
 Via Composer Create-Project :- Using commend composer create-
project laravel/laravel [directory]
(see:- http://www.youtube.com/watch?v=DD_-
l5AZY1A&feature=youtu.be )
 Using commend install composer ( see:-
http://www.youtube.com/watch?v=WW1CPLOzRH4&feature=youtu.be
)
 Generate key :- using commend php artisan key:generate (see :-
http://www.youtube.com/watch?v=87bYRrzCSUw&feature=youtu.be )
 Copy that unique generate key and paste into ‘app/config/app.php
file.
 Rename ‘server.php’ to ‘index.php’ .
Author : Vikas Chauhan
6
Task 3 :- Run Laravel
 Enter the url http://localhost/laravellab/public/ on
browser. (url should be change according to your localhost path.)
Author : Vikas Chauhan
7
Exercise 2
Write Hello World
Author : Vikas Chauhan
8
Task 1 :- Create welcome controller
 Using commend php artisan controller:make WelcomeController
(see :-
http://www.youtube.com/watch?v=BeIiGERN1tc&feature=youtu.
be )
Author : Vikas Chauhan
9
Task 2 :- Create welcome action
See:- https://gist.github.com/leonguyen/6000768
Author : Vikas Chauhan
10
Task 3 :- Routing Welcome Controller
See:- https://gist.github.com/leonguyen/6000930
Author : Vikas Chauhan
11
Task 4 :- Run
 Enter URL http://localhost/laravellab/index.php/welcome on the
browser .
Author : Vikas Chauhan
12
Exercise 3
Laravel Blade
Author : Vikas Chauhan
13
Task 1 :- app -> Controller -> DemoController
<?php class DemoController extends BaseController
{
public $restful = true;
public function get_index()
{
$title = ‘laravel page';
$View= View::make('demo1.index' , array(
'name'=>laravel user',
'age'=>'28',
'location'=>'bangalore'))
->with('title',$title);
return $View;
}
}
Author : Vikas Chauhan
14
Task 2 :- app ->View -> demo1 -> index.blade.php
<h1>My first controller</h1>
@if(isset($name))
{{ $age }} <br/>
@else
{{ $name }} <br/>
@endif
{{ $age }} <br/>
{{ $location }} <br/>
Author : Vikas Chauhan
15
Task 3 :- app-> route.php
Route::controller('demo1','DemoController');
Task 5 :- Run
Enter URL http://localhost/laravellab/index.php/demo1 on the
browser
Author : Vikas Chauhan
16
Exercise 4
Laravel Blade Layout
Author : Vikas Chauhan
17
Task 1 :- app -> Controller -> DemoController
<?php class DemoController extends BaseController
{
public $restful = true;
public $layout = 'layout.default';
public function get_index()
{
$this->layout->title = laravelpage';
$View= View::make('demo1.index' , array(
'name'=>Laravel user',
'age'=>'28',
'location'=>'bangalore'));
$this->layout->content= $View;
}
}
Author : Vikas Chauhan
18
Task 2 :- app ->View -> demo1 -> index.blade.php
<h1>My first controller</h1>
@if(isset($name))
{{ $age }} <br/>
@else
{{ $name }} <br/>
@endif
{{ $age }} <br/>
{{ $location }} <br/>
Author : Vikas Chauhan
19
Task 3 :- app ->View -> demo1 -> index.blade.php
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>{{ $title }}</title>
</head>
<body>
{{ $content }}
</body>
</html>
Author : Vikas Chauhan
20
Task 4 :- app-> route.php
Route::controller('demo1','DemoController');
Task 5 :- Run
Enter URL http://localhost/laravellab/index.php/demo1 on the browser
Author : Vikas Chauhan
21
Exercise 5
Types of Route
Author : Vikas Chauhan
22
Echo by route:- route.php
Route::get (‘about’, function() {
return “hello world”;
});
Echo by view:-
in view folder create a php file named hello
route.php :-
Route::get (‘/’, function() {
return view::make(‘hello’);
});
Author : Vikas Chauhan
23
Echo by only controller:-
route.php :-
Route::resource(‘demo1’, ‘controllername);
In controller
<?php class DemoController extends BaseController
{
public function get_index()
{
echo ‘hello world’;
}
}
Author : Vikas Chauhan
24
Echo by controller and view:-
route.php :-
Route::controller(‘demo1’, ‘controllername);
In controller :-
<?php class DemoController extends BaseController
{
public function get_index()
{
$View= View::make('demo1.index' , array(
'name'=>’laravel user ‘ )) ;
return $View;
}
}
In view :- create a folder named demo1 and make a php fiile named
index.php
Author : Vikas Chauhan
25
Restful route:-
route.php :-
Route::controller(‘pathname’, ‘controllername@function_name’);
In controller :-
<?php class DemoController extends BaseController
{
public function get_index()
{
$View= View::make('demo1.index' , array(
'name'=>’laravel User ‘ )) ;
return $View;
}
}
In view :- create a folder named demo1 and make a php fiile named
index.php
Author : Vikas Chauhan
26
Thanks & Regards,
Contact to – Vikas Chauhan
Email ID – vikas.chauhan@braincoerce.com
Phone – (080) 41155974

Laravel Beginners Tutorial 1

  • 1.
    1 Author :Vikas Chauhan Presented By: Vikas Chauhan Software Engineer, BrainCoerce Technologies, Bangalore Date – 08/08/2013
  • 2.
    2  Exercise 1:- Installation and configuration  Exercise 2 :- Write Hello World Program  Exercise 3 :- Laravel Blade  Exercise 4 :- Laravel Blade & Layout  Exercise 5:- Types of Route Author : Vikas Chauhan
  • 3.
    3 Exercise 1 Installation andconfiguration Author : Vikas Chauhan
  • 4.
    4 Task 1 :-Install Composer. - Go to http://getcomposer.org/ and download. Author : Vikas Chauhan
  • 5.
    5 Task 2 :-Install & configure Laravel  Via Composer Create-Project :- Using commend composer create- project laravel/laravel [directory] (see:- http://www.youtube.com/watch?v=DD_- l5AZY1A&feature=youtu.be )  Using commend install composer ( see:- http://www.youtube.com/watch?v=WW1CPLOzRH4&feature=youtu.be )  Generate key :- using commend php artisan key:generate (see :- http://www.youtube.com/watch?v=87bYRrzCSUw&feature=youtu.be )  Copy that unique generate key and paste into ‘app/config/app.php file.  Rename ‘server.php’ to ‘index.php’ . Author : Vikas Chauhan
  • 6.
    6 Task 3 :-Run Laravel  Enter the url http://localhost/laravellab/public/ on browser. (url should be change according to your localhost path.) Author : Vikas Chauhan
  • 7.
    7 Exercise 2 Write HelloWorld Author : Vikas Chauhan
  • 8.
    8 Task 1 :-Create welcome controller  Using commend php artisan controller:make WelcomeController (see :- http://www.youtube.com/watch?v=BeIiGERN1tc&feature=youtu. be ) Author : Vikas Chauhan
  • 9.
    9 Task 2 :-Create welcome action See:- https://gist.github.com/leonguyen/6000768 Author : Vikas Chauhan
  • 10.
    10 Task 3 :-Routing Welcome Controller See:- https://gist.github.com/leonguyen/6000930 Author : Vikas Chauhan
  • 11.
    11 Task 4 :-Run  Enter URL http://localhost/laravellab/index.php/welcome on the browser . Author : Vikas Chauhan
  • 12.
  • 13.
    13 Task 1 :-app -> Controller -> DemoController <?php class DemoController extends BaseController { public $restful = true; public function get_index() { $title = ‘laravel page'; $View= View::make('demo1.index' , array( 'name'=>laravel user', 'age'=>'28', 'location'=>'bangalore')) ->with('title',$title); return $View; } } Author : Vikas Chauhan
  • 14.
    14 Task 2 :-app ->View -> demo1 -> index.blade.php <h1>My first controller</h1> @if(isset($name)) {{ $age }} <br/> @else {{ $name }} <br/> @endif {{ $age }} <br/> {{ $location }} <br/> Author : Vikas Chauhan
  • 15.
    15 Task 3 :-app-> route.php Route::controller('demo1','DemoController'); Task 5 :- Run Enter URL http://localhost/laravellab/index.php/demo1 on the browser Author : Vikas Chauhan
  • 16.
    16 Exercise 4 Laravel BladeLayout Author : Vikas Chauhan
  • 17.
    17 Task 1 :-app -> Controller -> DemoController <?php class DemoController extends BaseController { public $restful = true; public $layout = 'layout.default'; public function get_index() { $this->layout->title = laravelpage'; $View= View::make('demo1.index' , array( 'name'=>Laravel user', 'age'=>'28', 'location'=>'bangalore')); $this->layout->content= $View; } } Author : Vikas Chauhan
  • 18.
    18 Task 2 :-app ->View -> demo1 -> index.blade.php <h1>My first controller</h1> @if(isset($name)) {{ $age }} <br/> @else {{ $name }} <br/> @endif {{ $age }} <br/> {{ $location }} <br/> Author : Vikas Chauhan
  • 19.
    19 Task 3 :-app ->View -> demo1 -> index.blade.php <!doctype html> <html lang="en"> <head> <meta charset="UTF-8"> <title>{{ $title }}</title> </head> <body> {{ $content }} </body> </html> Author : Vikas Chauhan
  • 20.
    20 Task 4 :-app-> route.php Route::controller('demo1','DemoController'); Task 5 :- Run Enter URL http://localhost/laravellab/index.php/demo1 on the browser Author : Vikas Chauhan
  • 21.
    21 Exercise 5 Types ofRoute Author : Vikas Chauhan
  • 22.
    22 Echo by route:-route.php Route::get (‘about’, function() { return “hello world”; }); Echo by view:- in view folder create a php file named hello route.php :- Route::get (‘/’, function() { return view::make(‘hello’); }); Author : Vikas Chauhan
  • 23.
    23 Echo by onlycontroller:- route.php :- Route::resource(‘demo1’, ‘controllername); In controller <?php class DemoController extends BaseController { public function get_index() { echo ‘hello world’; } } Author : Vikas Chauhan
  • 24.
    24 Echo by controllerand view:- route.php :- Route::controller(‘demo1’, ‘controllername); In controller :- <?php class DemoController extends BaseController { public function get_index() { $View= View::make('demo1.index' , array( 'name'=>’laravel user ‘ )) ; return $View; } } In view :- create a folder named demo1 and make a php fiile named index.php Author : Vikas Chauhan
  • 25.
    25 Restful route:- route.php :- Route::controller(‘pathname’,‘controllername@function_name’); In controller :- <?php class DemoController extends BaseController { public function get_index() { $View= View::make('demo1.index' , array( 'name'=>’laravel User ‘ )) ; return $View; } } In view :- create a folder named demo1 and make a php fiile named index.php Author : Vikas Chauhan
  • 26.
    26 Thanks & Regards, Contactto – Vikas Chauhan Email ID – vikas.chauhan@braincoerce.com Phone – (080) 41155974

Editor's Notes

  • #18 ‘layout’is a folder in view and ‘default’ is file in ‘layout’ folder.