Upload
vikas-chauhan
View
38.728
Download
2
Embed Size (px)
Citation preview
1
Laravel Beginners Tutorial 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
Laravel Beginners Tutorial 1
Author : Vikas Chauhan
4
Task 1 :- Install Composer. - Go to http://getcomposer.org/ and download.
Laravel Beginners Tutorial 1
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’ .
Laravel Beginners Tutorial 1
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.)
Laravel Beginners Tutorial 1
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 )
Laravel Beginners Tutorial 1
Author : Vikas Chauhan
9
Task 2 :- Create welcome actionSee:- https://gist.github.com/leonguyen/6000768
Laravel Beginners Tutorial 1
Author : Vikas Chauhan
10
Task 3 :- Routing Welcome ControllerSee:- https://gist.github.com/leonguyen/6000930
Laravel Beginners Tutorial 1
Author : Vikas Chauhan
11
Task 4 :- Run Enter URL http://localhost/laravellab/index.php/welcome on the
browser .
Laravel Beginners Tutorial 1
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;}
}
Laravel Beginners Tutorial 1
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/>
Laravel Beginners Tutorial 1
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
Laravel Beginners Tutorial 1
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;
}}
Laravel Beginners Tutorial 1
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/>
Laravel Beginners Tutorial 1
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>
Laravel Beginners Tutorial 1
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
Laravel Beginners Tutorial 1
Author : Vikas Chauhan
22
Echo by route:- route.phpRoute::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’);});
Laravel Beginners Tutorial 1
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’; }
}
Laravel Beginners Tutorial 1
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
Laravel Beginners Tutorial 1
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
Laravel Beginners Tutorial 1
Author : Vikas Chauhan
26
Thanks & Regards,Contact to – Vikas ChauhanEmail ID – [email protected] – (080) 41155974