laravel入门
安装过程可参考https://blog.csdn.net/example440982/article/details/86708165
laravel解决vendor缺失的问题:
直接在项目根目录下运行命令composer install
新建一个项目blog
根目录在blog/public/
nginx配置文件加上
location / {
try_files $uri $uri/ /index.php?$query_string;
}
\blog\app\Http\Controllers\TestController.php
新建控制器,内容如下
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Redis;
use Illuminate\Support\Facades\DB;
use App\Http\Controllers\Controller;
class TestController extends Controller
{
public function testApi(Request $request)
{
// 对请求的业务处理
return 'test';
}
}
blog\routes\api.php添加内容
Route::any("testApi", "TestController@testApi");
直接访问:
http://dev.laraveldemo.cc/api/testApi
结果: