PHPackages                             themallen/jsend - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. themallen/jsend

ActiveLibrary[API Development](/categories/api)

themallen/jsend
===============

JSend is a library intended to make outputting data for RESTful responses easy and painless using the super simple JSend specification.

06PHP

Since Jan 6Pushed 11y agoCompare

[ Source](https://github.com/TheMallen/JSend)[ Packagist](https://packagist.org/packages/themallen/jsend)[ RSS](/packages/themallen-jsend/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

### JSend

[](#jsend)

This lightweight JSend library was built because I needed an easy way to write responses to REST queries. I wanted to use a standard that was simple and clear, and I found one in [JSend](http://labs.omniti.com/labs/jsend). I tried my best to create a jQueryesque fluent interface for it. Basically everything is chainable, and mutators are get/set hybrids.

TODO: The ability to pass a jSend output into a jSend constructor would almost certainly be a good idea. In many cases they will be processed by javascript, but sometimes multiple php processes may need to send eachother jsons.

### Updates

[](#updates)

- Added security prefixing.

### Installing

[](#installing)

For composer, add `"themallen/jsend": "dev-master"` to your `require` object.

For anyone else, just `git clone` the repo into your desired folder and add it to whatever include\_path or autoloader solution you're using. For example, in codeigniter you would install it to the `application/libraries` folder.

### Example usage

[](#example-usage)

#### Configure a jSend manually

[](#configure-a-jsend-manually)

You simply use the mutators passing in your desired data. You can echo the object directly in your response thanks to \_\_toString() automagically `json_encode`ing for you.

```
