-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Description
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.
Another thing to note is that a prefix
or domain
will be required now. You can set these via the environment variables API_PREFIX
or API_DOMAIN
respectively, or by publishing the config and making the appropriate changes.