hello:
controller quản lý các action ví dụcontroller bằng artisanphp artisan make:controller ExampleController
controllerapp/Http/Controllers/ExampleController.phproutes/web.php// route Hiển thị màn hình hello
Route::get('/hello', 'ExampleController@hello')->name('example.hello');
/hello để điều hướng đến thực thi action hello trong ExampleControllerphp artisan route:list
hello():hello() thường dùng để hiển thị màn hình chào mừng với chữ HELLO LARAVELapp/Http/Controllers/ExampleController.php<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
class ExampleController extends Controller
{
    public function hello()
    {
        // khi gọi hàm view(), có một số lưu ý: 
        // - Mặc định thư mục gốc là `resources/views`
        // - Từ thư mục gốc, việc phân cách thư mục sẽ sử dụng dấu .
        // - Tên view không cần khai báo đuôi file (extension) `blade.php`
        
        // => view được gọi hiển thị sẽ nằm trong thư mục `resources/views/example/hello.blade.php'
        return view('example.hello');
    }
}
index.blade.phpController, mỗi action sẽ tương ứng với tên view.resources/views/exampleresources/views/example/hello.blade.php<div style="background-color: #DAE8FC; text-align: center; ">
    <h1>HELLO LARAVEL</h1>
    <a href="https://nentang.vn">nentang.vn</a>
</div>
php artisan serve để khởi động serverrequest GET được gởi thông qua các URL sau:
/gioithieubanthan: hiển thị view thông tin giới thiệu bản thân của bạn/hoctap/php: hiển thị view giới thiệu vài dòng ngắn gọn PHP là gì?/hoctap/laravel: hiển thị view cho biết phiên bản mới nhất của Laravel là bao nhiêu?/ngayhomnay: hiển thị view cho biết hôm nay ngày mấy? Bây giờ là mấy giờ? Theo định dạng dd/mm/yyyy HH:mm:ssThực hiện các bước tuần tự theo nội dung Bài học nhé!
Cùng nhau học tập, khám phá các kiến thức nền tảng về Lập trình web, mobile, database nhé.
Nền tảng kiến thức - Hành trang tới tương lai hân hạnh phục vụ Quý khách!
Khám phá, trải nghiệm ngay
          
Vui lòng đăng nhập để gởi bình luận!
Đăng nhậpChưa có bình luận nào!