7月3日下午 微擎芸众商城 设计思路

 

学习参考文章 https://learnku.com/articles/13622/the-principle-of-laravel-routing-execution

<?php

namespace appcommonproviders;

use appcommonservicesCheck;
use IlluminateSupportFacadesRoute;
use IlluminateFoundationSupportProvidersRouteServiceProvider as ServiceProvider;

class RouteServiceProvider extends ServiceProvider
{
/**
* This namespace is applied to your controller routes. 定义当前 Laravel 应用控制器路由的命名空间。
*/
protected $namespace = 'app';

/**
* Define your route model bindings, pattern filters, etc. 定义路由绑定、正则过滤等。
*/
public function boot()
{

parent::boot();
}

/**
* Define the routes for the application. 定义应用的路由。
*/
public function map()
{
if (env('APP_Framework') == 'platform') {
$this->mapWebBootRoutes();
$this->mapPlatformRoutes();
$this->mapShopRoutes();
$this->mapApiRoutes();
} else {
$this->mapWebRoutes();
}
}

/**
* Define the "web" routes for the application. 定义应用 Web 路由。
*
* These routes all receive session state, CSRF protection, etc. 这里定义的所有路由都会处理会话状态和 CSRF 防护等处理。
*/
protected function mapWebRoutes()
{
Route::group([
'middleware' => ['web'],
'namespace' => $this->namespace,
], function ($router) {
require base_path('routes/web.php');
});
}

protected function mapWebBootRoutes()
{
Route::group([
'prefix' => 'api',
'middleware' => ['web'],
'namespace' => $this->namespace,
], function ($router) {
require base_path('routes/boot.php');
});
}

/**
* 前端路由
*
*/

protected function mapApiRoutes()
{
Route::group([
'middleware' => ['web'],
'namespace' => $this->namespace,
], function ($router) {
require base_path('routes/api.php');
});
}

/**
* 框架路由
*
*/
protected function mapPlatformRoutes()
{
Route::group([
'prefix' => 'admin',
'middleware' => ['admin'],
'namespace' => $this->namespace,
], function ($router) {
require base_path('routes/admin.php');
});
}

/**
* 商城路由
*
*/
protected function mapShopRoutes()
{
Route::group([
'prefix' => 'admin',
'middleware' => ['admin'],
'namespace' => $this->namespace,
], function ($router) {
require base_path('routes/shop.php');
});
}

}

 

查看商城首页链接:   http://yunzhong.gysr.top/addons/yun_shop/?menu=#/home?i=2  前端商城用的vue框架

 

路由分发

这一节我们主要讲解 HTTP 如何被分发到相关路由并执行路由设置的回调(或控制器)。

如果你有了解过 Laravel 生命周期的话,应该知道所有的 HTTP 请求都是由 IlluminateFoundationHttpkernel::class内核处理的,而捕获 HTTP 请求操作位于项目的入口文件 public/index.php 中。

 前端页面api 地址:  http://yunzhong.gysr.top/addons/yun_shop/api.php?i=2&uuid=0&type=1&shop_id=null&route=home-page.index&

原文地址:https://www.cnblogs.com/guiyishanren/p/11126169.html