laravel写api接口

2018-03-12  本文已影响0人  紫微圣君

简要描述:

举例:

<?php

/*
|--------------------------------------------------------------------------
| API Routes
|--------------------------------------------------------------------------
|
| Here is where you can register API routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| is assigned the "api" middleware group. Enjoy building your API!
|
*/

// api
Route::group(array('domain' => 'abc.com'), function()
{
    Route::any('/', function() {
        $ctrl = \App::make("\\App\\Http\\Controllers\\" . ucfirst('api') . "\\" . ucfirst('index') . "Controller");
        return \App::call([$ctrl, ucfirst('index')]);
    });
});

注意:

https://abc.com/api/
上一篇 下一篇

猜你喜欢

热点阅读