Download the PHP package trabdlkarim/lararestler without Composer
On this page you can find all versions of the php package trabdlkarim/lararestler. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download trabdlkarim/lararestler
More information about trabdlkarim/lararestler
Files in trabdlkarim/lararestler
Package lararestler
Short Description A package for having Restler API in your Laravel application.
License MIT
Informations about the package lararestler
Restler for Laravel
Lararestler is a simple package that lets you to take advantage of all the features from both Restler 5 and Laravel as your API backend. With this package you can seamlessly integrate Restler into your existing laravel application without any hassle.
Installation
You can easily install this package with conmposer
.
[!WARNING] You should note that this package works actually with Laravel framework
^12.x
.
After the installation, you must publish the package assets for customization. Run the following command:
The following files should be generated if everything works fine:
config/lararestler.php
resources/views/vendor/lararestler/explorer.blade.php
public/vendor/lararestler/*
Now, feel free to change or modifiy any of these files as needed, to adapt them to your project.
Usage
Before starting writting your API, make sure you've properly set the API resource namespace
in config/lararestler.php
.
The default namespace is App\Http\Resources
.
Add Resources to API
Create a new class and extend Mirak\Lararestler\Http\Resources\Resource
class.
Add all the needed private and public methods as you would do with Restler.
Let's define a basic API class called Users
as an example.
Note that we make use of Mirak\Lararestler\Attributes\QueryParam
contextual attribute to caputure relevant query parameters from the current request.
There is also another attribute Mirak\Lararestler\Attributes\RequestBody
, useful when you want to capture all request body as an array.
Afterwards, you need to add your newly created resource class to the API resources
array in config/lararestler.php
file as shown below.
That's it, you're done! Visit the Explorer at {APP_URL}/api/explorer
to play with the API.
Request Models
Your request models should extend Mirak\Lararestler\Http\Requests\Model
class as follows:
Then, you could inject them into your resource class methods and use them as an instance of Laravel Illuminate\Http\Request
class.
Check the example below.
Protected API Routes
To protect a route in your resource class, simply add the @middleware
annotation, followed by the name of the middleware, to the method documentation.
Contributing
Thank you for considering contributing to this package! You should take a look at the contribution guide here.
Code of Conduct
In order to ensure that the Lararestler community is welcoming to all, please review and abide by the Code of Conduct.
Security
If you discover a security vulnerability within this package, please send me an e-mail via [email protected]. All security vulnerabilities will be promptly addressed.
License
This is an open-sourced software licensed under the MIT license.
All versions of lararestler with dependencies
illuminate/contracts Version ^12.14
illuminate/http Version ^12.14
illuminate/support Version ^12.14
illuminate/validation Version ^12.14
restler/framework Version ^5.0