dingo API 支持 Laravel5 和 Lumen 了,速去围观。

分享 jinqibu ⋅ 于 2年前 ⋅ 最后回复由 fantiq 1年前 ⋅ 15704 阅读

啥也不说了,直接上链接。

https://github.com/dingo/api/issues/398

以下是Jason的原文

Hello all, I've recently pushed quite a number of changes to the develop branch that allows you to use this package in your Lumen and Laravel 5 apps.

You can require it using 0.9.*@dev.

Please note that if you're using Lumen you'll need to be using lumen-framework 5.0.*@dev for it to work correctly. These several routing changes that are yet to make it to a stable Lumen release.

A few things to note...

Much of the configuration can be done via environment variables now. You can still publish the config file in Laravel 5 and make changes that way. Lumen will require you to use the environment variables. For things that can't be set with environment variables there will be a method available on the underlying instance to change whatever it is you need. There is no internal dispatcher at this point in time. I was focusing on the core of the API for now to make that that's all sweet before moving on to the internal dispatcher. There is no route command at this point in time. It will be back. There is no URL generator at this point in time. it will be back. There's no facade at the moment. You will need to get an instance of the API router (app('api.router')) to register your routes. Here is a very quick sample of how it's now used. In your Lumen bootstrap/app.php file you'd register the Lumen provider.

$app->register('Dingo\Api\Provider\LumenServiceProvider');

// Get an instance of the API router so we can use it in the routes.php file
 $api = $app['api.router'];

Now we can register our routes in the routes.php file.

$api->version('v1', function ($api) {
    $api->resource('users', 'UserController');
});

All routing methods available in L5 are available in both L5 and Lumen. This includes standard routing with get, post, etc, as well as resource and controller routes.

You can also setup group options much like in previous options (there is also an $api->group() method).

$api->version('v1', ['namespace' => 'App', 'protected' => true], function ($api) {
   $api->resource('users', 'UserController');
});

Aside from that not a whole lot has changed but there are a few new things that I'll be talking about over time. For now, I'd love it if people could give it a whirl and let me know if they come across any issues. I'll iron things out as quick as I can.

Cheers.

本帖已被设为精华帖!
回复数量: 17
  • Summer MOD A Life-long learner.
    2年前

    太棒啦 :+1: @JobsLong @lijinma @NauxLiu

  • NauxLiu https://github.com/nauxliu
    2年前

    @Summer 激动得无以言表,只能默默点个赞。

  • kenneth 极客地图创始人
    2年前

    一直在等这包更新,看来l5大势所趋,大家快跟上。

  • kenneth 极客地图创始人
    2年前
    [RuntimeException]
      Unable to boot ApiServiceProvider, configure an API domain or prefix.
  • MrJing MOD
    2年前

    喜大普奔,这是不是意味着 phphub 要改为 Laravel5 驱动了啊

  • Breezess
    2年前

    虽然没用过,但是必须围观

  • kenneth 极客地图创始人
    2年前

    安装可以,不过好像还很多没实现,用不起来。

  • RryLee 还什么都没有哦
    2年前

    没用过,围观起来

  • lijinma 就喜欢折腾。
    2年前

    @Summer 谢谢 Summer 老大,普大喜奔。。。哈哈哈哈哈

    太爽啦,嘎嘎。

  • yanguanglan
    2年前

    Lumen route部分不支持吧。0.9.*@dev 我现在打算用Lumen做后端API.

  • zhuzhichao Lalala Demacian !
    2年前

    等了太久了,上个月天天看他的更新,都没有L5的,如今项目已经做了好多了,只能等下个项目用上了。

  • jinqibu
    2年前

    现在并没有很完善,只是开发测试版,看来要用上还要一段时间。

  • JobsLong 那么,下一步的行动是什么?
    2年前

    @Summer 收到 等好久了

  • daimonhunter
    2年前

    lumen 和 laravel5 都试过

    按照文档 require 添加 :"dingo/api": "0.9.*@dev"

    执行 composer update

    报错:

    Problem 1

    - Installation request for dingo/api 0.9.*@dev -> satisfiable by dingo/api[0.9.x-dev].
    - dingo/api 0.9.x-dev requires illuminate/routing 5.1.* -> no matching package found.
  • zhaozhenxiang
    2年前

    是做RESTful的吗? 还是做其他的? RESTful的话laravel本身就可以做到呀。 求解释

  • bluewind86
    2年前

    @daimonhunter 同样的问题,望解决

  • fantiq
    1年前

    项目中使用了这个, 很多问题, 后来一点点的解决下来, 最终基本没有这个东西的功能。现在的这个东西只是一个壳

暂无评论~~
  • 请注意单词拼写,以及中英文排版,参考此页
  • 支持 Markdown 格式, **粗体**、~~删除线~~、`单行代码`, 更多语法请见这里 Markdown 语法
  • 支持表情,使用方法请见 Emoji 自动补全来咯,可用的 Emoji 请见 :metal: :point_right: Emoji 列表 :star: :sparkles:
  • 上传图片, 支持拖拽和剪切板黏贴上传, 格式限制 - jpg, png, gif
  • 发布框支持本地存储功能,会在内容变更时保存,「提交」按钮点击时清空
  请勿发布不友善或者负能量的内容。与人为善,比聪明更重要!
Ctrl+Enter