Laravel 5 framework
The Laravel framework has a few system requirements. Of course, all of these requirements are satisfied by the Laravel Homestead virtual machine, so it's highly recommended that you use Homestead as your local Laravel development environment.
Chu畉n b畛 m担i tr動畛ng
- Server web (XAMPP, WAMSERVER, )
- Larabel 5
Download: https://github.com/laravel/laravel
- Composer
Download: https://getcomposer.org/
- Th棚m bi畉n m担i tr動畛ng php
Th棚m vo bi畉n path th動 m畛c php trong web server.
1 of 30
More Related Content
Laravel 5 framework
1. TRAINING LARAVEL 5 FRAMEWORK 04/13/2016
HIEU TRAN TRUNG 1
LARAVEL 5 FRAMEWORK
TABLE OF CONTENTS
1. Gi畛i thi畛u Laravel 5..........................................................................................................................2
2. Download v ci 畉t ........................................................................................................................2
2.1. Chu畉n b畛 m担i tr動畛ng................................................................................................................2
2.2. Ti畉n hnh ci 畉t .....................................................................................................................3
2.2.1. S畛 d畛ng install composer vo th動 m畛c ch畛a project ...........................................................3
2.2.2. S畛 d畛ng l畛nh t畉o project v畛i command line.........................................................................6
3. C叩c thnh ph畉n c董 b畉n c畛a Laravel .................................................................................................9
3.1. Routing....................................................................................................................................9
3.2. T狸m hi畛u c畉u tr炭c MVC trong Laravel..................................................................................... 12
4. C叩c Command line s畛 d畛ng trong Laravel 5 ..................................................................................20
5. p d畛ng project th畛c t畉 - web b叩n hng........................................................................................ 21
5.1. Ph但n t鱈ch ch畛c nng v c董 s畛 d畛 li畛u..................................................................................... 21
5.1.1. Ch畛c nng c畛a website .................................................................................................. 21
5.1.2. C董 s畛 d畛 li畛u.................................................................................................................. 21
5.2. Kh畛i t畉o project v ch畉y th畛.................................................................................................. 21
5.3. T畉o database s畛 d畛ng Migrate ..............................................................................................25
5.4. C畉u h狸nh cho model theo c叩c b畉ng 達 t畉o trong database 畛 thi畉t l畉p quan h畛 gi畛a c叩c b畉ng
27
5.5. Thi畉t k畉 giao di畛n 畛 folder views ...........................................................................................28
2. TRAINING LARAVEL 5 FRAMEWORK 04/13/2016
HIEU TRAN TRUNG 2
1. GI畛I THI畛U LARAVEL 5
Laravel l framework opensource s畛 d畛ng ng担n ng畛 PHP d湛ng 畛 ph叩t tri畛n c叩c h畛 th担ng websites
l畛n d畛 dng cho vi畛c ph叩t tri畛n n棚n 動畛c c担ng 畛ng l畉p tr狸nh vi棚n s畛 d畛ng r畛ng r達i.
2. DOWNLOAD V CI 畉T
2.1. Chu畉n b畛 m担i tr動畛ng
- Server web (XAMPP, WAMSERVER, )
- Larabel 5
Download: https://github.com/laravel/laravel
- Composer
Download: https://getcomposer.org/
- Th棚m bi畉n m担i tr動畛ng php
Th棚m vo bi畉n path th動 m畛c php trong web server.
3. TRAINING LARAVEL 5 FRAMEWORK 04/13/2016
HIEU TRAN TRUNG 3
2.2. Ti畉n hnh ci 畉t
2.2.1. S畛 d畛ng install composer vo th動 m畛c ch畛a project
- D湛ng command line download thnh ph畉n c畛a Laravel
4. TRAINING LARAVEL 5 FRAMEWORK 04/13/2016
HIEU TRAN TRUNG 4
Download thnh c担ng
8. TRAINING LARAVEL 5 FRAMEWORK 04/13/2016
HIEU TRAN TRUNG 8
- Ch畉y web demo: vo 動畛ng d畉n trong webserver v th動 m畛c public trong th動 m畛c 達
t畉o trong laravel
9. TRAINING LARAVEL 5 FRAMEWORK 04/13/2016
HIEU TRAN TRUNG 9
3. CC THNH PH畉N C B畉N C畛A LARAVEL
3.1. Routing
Ch畛c nng: i畛u h動畛ng c叩c request c畛a ng動畛i d湛ng.
- GET
LO畉I 1: i畛u h動畛ng theo request tr棚n url c畛a ng動畛i d湛ng.
M畛 file routers.php 畛 vi畉t i畛u h動畛ng
Code:
Route::get('hello-world', function () {
echo "Routes hello-world";
});
URL: http://localhost:6969/fwlaravel/laravel5/public/hello-world
Ch畉y i畛u h動畛ng tr棚n url c畛a tr狸nh duy畛t web:
29. TRAINING LARAVEL 5 FRAMEWORK 04/13/2016
HIEU TRAN TRUNG 29
@yield('content')
Khi 1 trang mu畛n s畛 d畛ng trang master th狸 k畉 th畛a t畛 master v ch畛n section v畛i t畛 kh坦a
t動董ng 畛ng
@extends('admin.master')
@section('content')
// code
@endsection('content')
C叩c code x畛 l箪 javascript v css 動畛c l動u 畛 folder public
Ch畛nh c叩c link c畛a css v js 炭ng 動畛ng d畉n
<link
href=/slideshow/laravel-5-framework/60869735/"{{ url('public/admin/bower_components/bootstrap/dist/css/bootstrap.min.css') }}"
rel="stylesheet">
<script
src=/slideshow/laravel-5-framework/60869735/"{{ url('public/admin/bower_components/jquery/dist/jquery.min.js') }}"></script>
5.6. T畉o controller 畛 x畛 l箪
M畛 command line 畛 folder g畛c 畛 ch畉y l畛nh t畉o controller
php artisan make:controller CateController
Vi畉t hm GET POST cho controller
30. TRAINING LARAVEL 5 FRAMEWORK 04/13/2016
HIEU TRAN TRUNG 30
class CateController extends Controller
{
public function getAdd () {
return view('admin.cate.add');
}
public function postAdd () {
}
}