Download the PHP package mrlijan/restmold without Composer
On this page you can find all versions of the php package mrlijan/restmold. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package restmold
Introduction
Restmold (pronounced /restː/ /mold:/) is a Laravel package for modeling 3rd party HTTP services and as an HTTP client. Using this package will allow you to model your external HTTP services. The magic behind Restmold is that you don't need to repeatedly re-code your API class services.
Inspiration
The inspiration for this project started when the company I worked for migrated our giant monolith into a bunch of small microservices. Time passed, and we found ourselves writing API services repeatedly as the number of services grew. So, inspired by the flow of Laravel's models, Restmold has born out.
:warning: The package supports Laravel 7 and above.
Installation
Usage
Restmold is so easy-to-use; you just need to run the generate command to create a new API model. As a result, a new folder named "ApiModels" will be created under the \App folder, including the new concrete class.
Class Structure
Each restmold concrete class will derive its props and methods from the RestModel abstract class and should also implement the following properties and methods to work properly:
| Type | Name | Description |
|---|---|---|
| Property | baseURI | The base uri for that specific service |
| Method | headers | Return the request's headers. This can be used for authentication |
| Method | routes | Used to construct the service's structure |
Class Configuration
the routes method is being used to construct the service's structure. This means that every array index listed below will be determined as a method for this service.
Each index of that array will be constructed as follows:
Config with Query Params
Your route includes query params? We've got your back! Just use the regular syntax, excluding the values. For example:
Implementations
Using Query Params
Once everything is ready and configured, the service is prepared to use.
Using request body
Piping Requests & Responses
Sometimes, collective pipes are necessary in some services, and for these cases, a request and response pipes have been created. In order to use them just override the following methods: