我在 laragon/www 文件夹中创建了我的 laravel 项目,并且我正在使用 dingo/api 包进行路由。
这是我的文件
路线/web.php
<?php
Route::get('/', function () {
return view('welcome');
});
路线/api.php
<?php
use Dingo\Api\Routing\Router;
$api->get('test', 'TestController@index');
应用程序/Http/Controllers/Api/TestController.php
<?php
namespace App\Http\Controllers\Api;
class TestController extends BaseController {
public function index() {
return 'test';
}
}
当我运行 artisan api/routes 它给了我 URI api/test 但是当我尝试在浏览器中的http://localhost/myproject/public/api/test下访问它时它返回错误“对不起,你正在寻找的页面for 找不到”知道http://localhost/myproject/public/返回好的结果