Download the PHP package nannehuiges/jsend without Composer
On this page you can find all versions of the php package nannehuiges/jsend. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download nannehuiges/jsend
More information about nannehuiges/jsend
Files in nannehuiges/jsend
Package jsend
Short Description A simple PHP implementation of the JSend specification.
License BSD-3-Clause
Homepage https://github.com/NanneHuiges/jsend
Informations about the package jsend
JSend
A simple PHP implementation of the JSend specification.
Usage
New response
Note: an InvalidJSendException
is thrown if the status is invalid or if you're creating an error
without a message
.
Convert JSendResponse to JSON
__toString()
is overridden to encode JSON automatically.
As JSendResponse is JsonSerializable
, you can use the object directly in json_encode
Setting flags
You can set flags if needed:
Convert JSON to JSendResponse
Send JSON as HTTP Response
This sets the Content-Type
header to application/json
and spits out the JSON.
Get info
Additionally, you can call the following methods on an error. A BadMethodCallException
is thrown if the status is not error
, so check first.
Development
For your convenience, there is a dockerfile with the right dependencies (php, composer) available. Please use those
to run various things (composer, phpunit, etc). You will need docker
installed, but you don't
need PHP
or composer
or any of the other dependencies.
Setting up and using a local environment
To start using the local environment for testing and debugging all you have to is open a shell in the root folder of where this project is checked out. Then run the following command.
This command should be run occasionally to keep the local environment up to date. For instance when the composer dependencies are changed.
Using the shell
To open a shell in the docker container run the following command.
Available commands are in /bin
Running the code quality tools locally
We use a variety of tools to keep the code quality of the library high. To run one the tools you only need to run
Available tools:
phpstan
PHPStan is static analyser tool that can detect various code issues.phpunit
PHPUnit is the unit testing framework we use for this library.codeclimate
CodeClimate
Notes
- Note that the
composer.lock
file is ignored.
Credits
The library was written by Jamie Schembri. It has been transfered to the current account Nanne Huiges in december 2015.
All versions of jsend with dependencies
ext-json Version *