drodsh7940 2016-12-17 17:01
浏览 190
已采纳

Laravel新API不起作用

I'm trying to learn Laravel (5.3.28) and I'm running into an issue with my very first api route not working. I've followed the Laravel docs and can create a new project and can navigate to the Laravel splash screen indicating it's working. I added the following route to routes/api.php to test if I can consume the end-point, but I get an error:

routes/api.php

Route::get('foo', function () {
    return 'Hello World';
});

error

NotFoundHttpException in RouteCollection.php line 161:

I have a dedicated CentOS box running XAMPP for my web server. the address to hit the end-point is http://10.0.0.200/test/api/public/foo.

I'm read that my .htaccess file should be edited, but the few examples I found match what I already have, so I'm a little lost on what to do.

Here is the output for php artisan route:list:

+--------+----------+----------+------+---------+--------------+
| Domain | Method   | URI      | Name | Action  | Middleware   |
+--------+----------+----------+------+---------+--------------+
|        | GET|HEAD | /        |      | Closure | web          |
|        | GET|HEAD | api/foo  |      | Closure | api          |
|        | GET|HEAD | api/user |      | Closure | api,auth:api |
+--------+----------+----------+------+---------+--------------+
  • 写回答

2条回答 默认 最新

  • duanpie2414 2016-12-17 17:43
    关注

    10.0.0.200/test/api/public is the root URL I assume. If yes, then you need to hit 10.0.0.200/test/api/public/api/foo

    I think that your project lies in the folder test/api, what you need is to reconfigure apache ginx to route all requests going to 10.0.0.200/test/ , to start going to {webser root}/test/api/public . This is done in web server configuration files

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 linux驱动,linux应用,多线程
  • ¥20 我要一个分身加定位两个功能的安卓app
  • ¥15 基于FOC驱动器,如何实现卡丁车下坡无阻力的遛坡的效果
  • ¥15 IAR程序莫名变量多重定义
  • ¥15 (标签-UDP|关键词-client)
  • ¥15 关于库卡officelite无法与虚拟机通讯的问题
  • ¥15 目标检测项目无法读取视频
  • ¥15 GEO datasets中基因芯片数据仅仅提供了normalized signal如何进行差异分析
  • ¥100 求采集电商背景音乐的方法
  • ¥15 数学建模竞赛求指导帮助