PS:目前所能找到的方法,希望不会被大佬们鄙视...
1、我的nginx配置:
#test6 admin server { listen 80; server_name admin.test6.local; root "d:/data/www/test6/public/admin"; index index.html index.htm index.php; error_page 404 /404.html; location = /404.html { return 404 'Sorry, File not Found!'; } error_page 500 502 503 504 /50x.html; location = /50x.html { root /usr/share/nginx/html; # windows dir } location / { try_files $uri $uri/ /index.php?$query_string; } location ~ /Uploads/.*\.php$ { deny all; } location ~ \.php/ { if ($request_uri ~ ^(.+\.php)(/.+?)($|\?)) { } fastcgi_pass 127.0.0.1:9000; include fastcgi_params; fastcgi_param SCRIPT_NAME $1; fastcgi_param PATH_INFO $2; fastcgi_param SCRIPT_FILENAME $document_root$1; } location ~ \.php$ { fastcgi_pass 127.0.0.1:9000; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } location ~ /\.ht { deny all; } }
2、路由 /routes/admin.php
PS:目前用的方法是这样的
Route::get('/shop/goods_list', 'Shop\GoodsController@goods_list'); Route::get('/shop/goods_list/page/{page}/limit/{limit}', 'Shop\GoodsController@goods_list'); Route::get('/shop/goods_list/page/{page}/limit/{limit}/keyword/{keyword}', 'Shop\GoodsController@goods_list');
3、基类 \app\Http\Controllers\Admin\Publi\BaseController.php
PS:请别吐槽那个Publi,我也很无奈啊..
<?php namespace App\Http\Controllers\Admin\Publi; use Illuminate\Foundation\Bus\DispatchesJobs; use Illuminate\Routing\Controller; use Illuminate\Foundation\Validation\ValidatesRequests; use Illuminate\Foundation\Auth\Access\AuthorizesRequests; use Illuminate\Http\Request; class BaseController extends Controller { use AuthorizesRequests, DispatchesJobs, ValidatesRequests; //构造函数 public function __construct() { $this->middleware(function ($request, $next) { //未登录的处理 //$this->dosomething($request); //仿TP用pathinfo传参 $path=$request->path(); $this->pathinfo=$this->path_to_array($request,$path); return $next($request); }); } /*路径转数组 *输入路径,如:http://admin.test6.local/shop/goods_list/page/3 * 返回数组,如:$array['page']=3; $array['keyword']='somekeyword'; */ public function path_to_array(Request $request,$path=null){ $array=array(); if(strpos($path,'/')!==false){ $arr=explode('/',$path); foreach($arr as $k=>$v){ if($k>0&&($k%2==0)){ $array[$v]=$arr[$k+1]; } } } if(count($array)>0){ return $array; } } }
3、控制器 \app\Http\Controllers\Admin\Shop\GoodsController.php
namespace App\Http\Controllers\Admin\Shop; use App\Http\Controllers\Admin\Publi\BaseController; use Illuminate\Http\Request; class GoodsController extends BaseController { public function goods_list(Request $request){ //获取参数 $page=1; $keyword=''; //当前页 if(is_array($this->pathinfo)){ //当前页 if (array_key_exists("page",$this->pathinfo)) { $page=$this->pathinfo['page']; } //关键词 if (array_key_exists("keyword",$this->pathinfo)) { $keyword=$this->pathinfo['keyword']; } } dump($page); dump($keyword); exit; } }
推荐:laravel教程
The above is the detailed content of Laravel5.5 imitates ThinkPHP's pathinfo parameter passing example. For more information, please follow other related articles on the PHP Chinese website!

React,Vue,andAngularcanbeintegratedwithLaravelbyfollowingspecificsetupsteps.1)ForReact:InstallReactusingLaravelUI,setupcomponentsinapp.js.2)ForVue:UseLaravel'sbuilt-inVuesupport,configureinapp.js.3)ForAngular:SetupAngularseparately,servethroughLarave

Taskmanagementtoolsareessentialforeffectiveremoteprojectmanagementbyprioritizingtasksandtrackingprogress.1)UsetoolslikeTrelloandAsanatosetprioritieswithlabelsortags.2)EmploytoolslikeJiraandMonday.comforvisualtrackingwithGanttchartsandprogressbars.3)K

Laravel10enhancesperformancethroughseveralkeyfeatures.1)Itintroducesquerybuildercachingtoreducedatabaseload.2)ItoptimizesEloquentmodelloadingwithlazyloadingproxies.3)Itimprovesroutingwithanewcachingsystem.4)ItenhancesBladetemplatingwithviewcaching,al

The best full-stack Laravel application deployment strategies include: 1. Zero downtime deployment, 2. Blue-green deployment, 3. Continuous deployment, and 4. Canary release. 1. Zero downtime deployment uses Envoy or Deployer to automate the deployment process to ensure that applications remain available when updated. 2. Blue and green deployment enables downtime deployment by maintaining two environments and allows for rapid rollback. 3. Continuous deployment Automate the entire deployment process through GitHubActions or GitLabCI/CD. 4. Canary releases through Nginx configuration, gradually promoting the new version to users to ensure performance optimization and rapid rollback.

ToscaleaLaravelapplicationeffectively,focusondatabasesharding,caching,loadbalancing,andmicroservices.1)Implementdatabaseshardingtodistributedataacrossmultipledatabasesforimprovedperformance.2)UseLaravel'scachingsystemwithRedisorMemcachedtoreducedatab

Toovercomecommunicationbarriersindistributedteams,use:1)videocallsforface-to-faceinteraction,2)setclearresponsetimeexpectations,3)chooseappropriatecommunicationtools,4)createateamcommunicationguide,and5)establishpersonalboundariestopreventburnout.The

LaravelBladeenhancesfrontendtemplatinginfull-stackprojectsbyofferingcleansyntaxandpowerfulfeatures.1)Itallowsforeasyvariabledisplayandcontrolstructures.2)Bladesupportscreatingandreusingcomponents,aidinginmanagingcomplexUIs.3)Itefficientlyhandleslayou

Laravelisidealforfull-stackapplicationsduetoitselegantsyntax,comprehensiveecosystem,andpowerfulfeatures.1)UseEloquentORMforintuitivebackenddatamanipulation,butavoidN 1queryissues.2)EmployBladetemplatingforcleanfrontendviews,beingcautiousofoverusing@i


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft

Zend Studio 13.0.1
Powerful PHP integrated development environment

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment
