Download the PHP package 4myth/api without Composer
On this page you can find all versions of the php package 4myth/api. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package api
MyTh API Manager
For Laravel 5.5 and higher
This package allows you to sync your data with Laravel 5.5 and higher. Contains two sections of manger and clint
Package Installation
Require this package in your composer.json and update composer.
Laravel
Laravel 5.5 uses Package Auto-Discovery, so doesn't require you to manually add the ServiceProvider/Facade.
You can use the Alias for shorter code.
Finally you can publish the package:
Getting Started
1- Manager Side
-
Config file:
The settings you need to setup of connection with your clients. your
name
and yourclients
.
Example multiple clients:
Example multiple models with clients:
Client config:
The key
of client array must be the client name in your application.
All options array keys: secret
,base_uri
,options
,models
secret
: Client's authentication secret, which you can obtain from your client.base_uri
: Client api url. Example:http://127.0.0.1/api/v1
options
: Array of your client options. available options:http
.http
: GuzzleHttp\Client options. See: http://docs.guzzlephp.org
models
: Array of your models, will be able tosyc
with specific client.uri
: Theurl
orprefix
of model at your client software.transformer
: This option will be used automatically when your system syncsend
model data to your client, you must make a new transformer for each client's model.
Setup
- Model.
- Model transformer.
Model
Before you begin to use the package you must setup your model by use package trait
.
Model transformer
first to make a new model transformer we have configure in our config, we can execute artisan command:
then we will find the transformer inside app directory app\TransformerName.php
Transformer file:
The body method must be return an array data that you will send when syncing this model with Client.
Example:
The client will receive in body request this array.
Usage
Access to client:
to access your client inside your application you can use the facade
package Api
Access to client models:
Send data to client
you can send your data with multiple ways:
Response
The response using class ResponseInterface
package contains methods you can access easily in your code
request
: \GuzzleHttp\Psr7\Response See: http://docs.guzzlephp.orgresponse
: array client responseclient_id
: the unique id at client in database.
Client locale storage
Mark your models
set must sync with client
set synced with client
unsync model with client Delete relation