JSON-RPC API server for Laravel framework
Extracto
Easy implementation of the JSON-RPC 2.0 server for the Laravel framework.
Contenido
Sajya is the most popular open-source package for Laravel that makes it easy to implement the JSON-RPC 2.0 server specification including validation of parameters, support for batch and notification requests, and more.
Easy to use
Request and response format is unified and easy to use, allowing even beginners to work.
Use any transport you prefer, including HTTP, WebSocket, Server Sent Events, or others.
Learn more about Specification.
{
"jsonrpc": "2.0",
"method": "subtract",
"params": {
"subtrahend": 23,
"minuend": 42
},
"id": 3
}
--> Request
{
"jsonrpc": "2.0",
"result": 19,
"id": 3
}
-- Response
Batch
Ability to send several requests in one API call. This helps reduce network costs and speed up your application.
Learn more about batch requests.
Notification
Send requests that do not need to be answered. Customers won't have to wait for the request to actually be fulfilled.
Learn more about notifications requests.
declare(strict_types=1);
namespace App\Http\Procedures;
use App\Models\User;
use Sajya\Server\Procedure;
class UserProcedure extends Procedure
{
public function update(User $user)
{
// ...
}
}
Binding
Bind values of query parameters to various objects such as Eloquent models, Enums and others, which allows you to work with data in your project quickly and conveniently.
Learn more about Binding.
Validation
Automatically validates incoming requests to ensure they meet your specifications. You can also customize the error messages that are returned if the validation fails.
Learn more about request validation.