Blogger Information
Blog 65
fans 2
comment 0
visits 60193
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
lavarel7学习笔记:下载安装+隐藏入口文件,路由匹配、控制器、传参+经验
张福根一修品牌运营
Original
1054 people have browsed it

2020-1-11 lavarel7学习笔记

一、下载安装

下载符合php版本最新
composer create-project —prefer-dist laravel/laravel blog
指定版本安装
composer create-project —prefer-dist laravel/laravel blog 7.3.*

二、隐藏入口文件

<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?/$1 [QSA,PT,L]
</IfModule>

三、路由匹配、控制器、传参

\mylaravel\routes
内核:mylaravel\vendor\laravel\framework\src\Illuminate

1、路由匹配
Route::gen(‘/product/lists’,function(){
echo ‘aaaa’;
});
//访问:http://lv.php.com/product/lists
//输出:aaaa

Route::get(‘/product/detail/{id}/{iidd}’,function($id,$iidd){
if($id==22){
echo ‘this is product detail:华为手机’;
}
if($id==33){
echo ‘this is product detail:华为电视’;
}
echo ‘<br>价格:’.$iidd.’元’;
});
//访问:http://lv.php.com/product/detail/22/55
//输出:this is product detail:华为手机
价格:55元

控制器:
class Article extends Controller
{
public function lists(){
echo “这是文章列表”;
}
}
路由:Route::get(‘/product/detail/‘,’Article@lists’);

四、经验:

1、学习的时候语言的时候,一般建议的版本是最新版本-1或-2;
2、Laravel7和Laravel8区别在路由的写法上,其他的基本没变。比如:
laravel7:Route::get(‘/article/index’,’article@index’);
laravel8:Route::get(‘/article/index’,[Article::class,’index’]);

lavarel7学习笔记

Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
1 comments
吾逍遥 2021-01-13 08:03:29
经验第2条有点误导人呢,可以看我测试后的总结https://www.php.cn/blog/detail/25944.html
1 floor
Author's latest blog post