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

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

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

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.

本文章首发在 Laravel China 社区
本帖已被设为精华帖!
回复数量: 17
  • Summer MOD A Life-long learner.
    3年前

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

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

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

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

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

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

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

  • Breezess
    3年前

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

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

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

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

    没用过,围观起来

  • lijinma 就喜欢折腾。
    3年前

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

    太爽啦,嘎嘎。

  • yanguanglan
    3年前

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

  • zhuzhichao Lalala Demacian !
    3年前

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

  • jinqibu
    3年前

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

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

    @Summer 收到 等好久了

  • daimonhunter
    3年前

    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
    3年前

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

  • bluewind86
    3年前

    @daimonhunter 同样的问题,望解决

  • fantiq
    2年前

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

暂无评论~~
您需要登陆以后才能留下评论!

Composer 中国全量镜像

Top 100 扩展包

Lumen 中文文档

Laravel 速查表

Laravel 中文文档

Laravel 项目开发规范

Laravel 开发环境部署

社区文档撰写指南

TDD 构建 Laravel 论坛笔记

PHP PSR 标准规范

PHP 设计模式全集

Dingo API 中文文档