This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //Route::请求方式($uri,回调函数/控制器@方法) | |
| 【0】关闭post请求验证机制 | |
| //--app/Http/Middleware/VerifyCsrfToken.php | |
| protected $except = [ | |
| '/test','/po','/admin' //添加一串post开放验证路径,注意使用数组 | |
| ]; | |
| //--routes/web.php |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //[1]指定安装目录 | |
| cd~ | |
| //[2]安装目录 | |
| composer create-project --prefer-dist laravel/laravel 目录名 项目名 "5.6.*" | |
| eg. | |
| composer create-project --prefer-dist laravel/laravel 5 "5.6.*" | |
| //[3]配置Nginx.config | |
| 【注意】把目录指向public!!! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 【0】创建控制器须知 | |
| //app\Http\Controllers\Controller.php 基类不要动 | |
| //遵循PSR-4 首字母必须大写 类名与文件名一样 一定要后缀Controller | |
| //app\Http\Controllers\ 可以在文件夹下面创建多个文件夹,注意命名空间 | |
| 【1】基本控制器 | |
| //--路由 | |
| Route::get('/xxx', 'Xxx\XXXController@index'); //如果有子文件夹,要加前缀,注意首字母大写 | |
| //--控制器 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 【1】基本方法:直接返回某个视图,不包括任何参数 | |
| //--控制器 | |
| return view('xxx'); | |
| //--视图 | |
| //--resources/views/xxx.blade.php | |
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <meta charset="utf-8"> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 【0】用于表单 使用token 免除跨站点请求伪造csrf攻击 | |
| //--app/Http/Middleware/VerifyCsrfToken.php | |
| //注意要删除csrf文件里的过滤 | |
| 【1】发送post请求 | |
| //--视图 | |
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <meta charset="utf-8"> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 【0】基本使用 | |
| //--路由 | |
| Route::get('/xxx','Xxx\XXXcontroller@index'); | |
| //--控制器 | |
| <?php | |
| namespace App\Http\Controllers\Xxx; | |
| use Illuminate\Http\Request; //引入命名空间 | |
| use App\Http\Controllers\Controller; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 【1】基本使用,不需要额外引入库 | |
| //--控制器 | |
| <?php | |
| namespace App\Http\Controllers\Xxx; | |
| use App\Http\Controllers\Controller; | |
| class XXXController extends Controller | |
| { | |
| public function index(){ | |
| $data=['info'=>'success']; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 【0】存放文件夹 | |
| //--public文件夹下 | |
| 【1】下载文件控制器 | |
| //--控制器 | |
| <?php | |
| namespace App\Http\Controllers\Xxx; | |
| use Illuminate\Http\Request; | |
| use App\Http\Controllers\Controller; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 【1】重定向基本使用 | |
| //--控制器 | |
| <?php | |
| namespace App\Http\Controllers\Xxx; | |
| use Illuminate\Http\Request; //可能不需要 | |
| use App\Http\Controllers\Controller; | |
| class XXXController extends Controller | |
| { | |
| public function index(Request $request){ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 【1】cookie的使用 | |
| //--控制器 | |
| <?php | |
| namespace App\Http\Controllers\Xxx; | |
| use Illuminate\Support\Request; | |
| use Illuminate\Support\Facades\Cookie; //引入cookie库 | |
| use App\Http\Controllers\Controller; | |
| class XXXController extends Controller | |
| { |
OlderNewer