Installation
Meet Lomkit
Lomkit is an organization dedicated to the Laravel community. We offer a collection of innovative open source packages for developers. Our commitment to sharing knowledge and expertise aims to make development easier, while keeping our packages up-to-date with the latest practices.
Join our collaborative ecosystem where community contributions are welcome. Together, we're building a more powerful and inclusive software development future, pushing the boundaries of innovation. Explore our packages, contribute and let us accompany you on your software development journey with enthusiasm and dedication.
Installing Laravel Rest Api
Install the package with:
composer require lomkit/laravel-rest-api
(Optional) Publish the config file:
php artisan vendor:publish --tag=rest-config
Setup your first project
Call the Laravel Rest Api quick start command:
php artisan rest:quick-start
This command will generate a UserResource, a UsersController and register them in your api.php route file.
You can also take a look at all available endpoints by running php artisan route:list
:
+-----------+-------------------------------------------------+----------------------------------------+
| Method | URI | Name |
+-----------+-------------------------------------------------+----------------------------------------+
| GET | api/users | api.users.details |
| POST | api/users/search | api.users.search |
| POST | api/users/actions/{action} | api.users.operate |
| POST | api/users/mutate | api.users.mutate |
| DELETE | api/users | api.users.destroy |
+-----------+-------------------------------------------------+----------------------------------------+
Setup your first project manually
- Setup your first resource:
php artisan rest:resource UserResource
- Create your controller:
php artisan rest:controller UsersController
- Setup the resource on the controller
class UsersController extends Controller {
public static $resource = App\Models\User::class;
}
- Register the route in your api.php file:
use \Lomkit\Rest\Facades\Rest;
Rest::resource('users', \App\Rest\Resources\UsersController::class)
You can also take a look at all available endpoints by running php artisan route:list
:
+-----------+-------------------------------------------------+----------------------------------------+
| Method | URI | Name |
+-----------+-------------------------------------------------+----------------------------------------+
| GET | api/users | api.users.details |
| POST | api/users/search | api.users.search |
| POST | api/users/actions/{action} | api.users.operate |
| POST | api/users/mutate | api.users.mutate |
| DELETE | api/users | api.users.destroy |
+-----------+-------------------------------------------------+----------------------------------------+