Skip to content

Latest commit

 

History

History
executable file
·
117 lines (86 loc) · 4.16 KB

File metadata and controls

executable file
·
117 lines (86 loc) · 4.16 KB

PHP Response Json

Latest Version codecov CI Build Downloads Old Downloads PRs Welcome Packagist License (custom server)

PHP library to create a response json pattern to API's

Installation

Release 8.0.0 Requires PHP 8.4

Release 7.0.0 Requires PHP 8.3

Release 6.0.0 Requires PHP 8.2

Release 5.0.0 Requires PHP 8.1

Release 4.0.0 Requires PHP 7.4

Release 3.0.0 Requires PHP 7.3

Release 2.0.0 Requires PHP 7.2

Release 1.0.0 Requires PHP 7.1

The recommended way to install is through Composer.

composer require not-empty/response-json-php-lib

Usage

Creating a response

use ResponseJson\ResponseJson;
$responseJson = new ResponseJson();
$token = [
    'token' => 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.' .
        'eyJhdWQiOiJ0ZXN0IiwiZXhwIjozMCwiaWF0I' .
        'joxNTYyMTcwOTIwLCJpc3MiOiJ0ZXN0Iiwic3' .
        'ViIjoiIn0=.wPdhZtjpyBjObFWbxPx33GNJpv' .
        'KHIznPV0GQ2NiQp5A=',
    'valid_until' => '2020-06-16 12:36:34',
];
$data = [
    'data' => 'test',
];
$response = $responseJson->response(
    'd0684895-cb6c-4c9a-a0aa-0aed7cfc1f46',
    microtime(true)-0.1,
    $token,
    $data,
    'message'
);
var_dump($response);

if you want an environment to run or test it, you can build and install dependences like this

docker build --build-arg PHP_VERSION=8.4-cli -t not-empty/response-json-php-lib:php84 -f contrib/Dockerfile .

Access the container

docker run --name response-json-php-lib -v ${PWD}/:/var/www/html -it not-empty/response-json-php-lib:php84 bash

Verify if all dependencies is installed

composer install --no-dev --prefer-dist

and run

php sample/response-json-sample.php

Development

Want to contribute? Great!

The project using a simple code. Make a change in your file and be careful with your updates! Any new code will only be accepted with all validations.

To ensure that the entire project is fine:

First you need to building a correct environment to install all dependences

docker build --build-arg PHP_VERSION=8.4-cli -t not-empty/response-json-php-lib:php84 -f contrib/Dockerfile .

Access the container

docker run --name response-json-php-lib -v ${PWD}/:/var/www/html -it not-empty/response-json-php-lib:php84 bash

Install all dependences

composer install --dev --prefer-dist

Run all validations

composer check

Not Empty Foundation - Free codes, full minds