<commit_before>[![Circle CI](https://circleci.com/gh/navjobs/transmit.svg?style=shield)](https://circleci.com/gh/navjobs/transmit)
[![Coverage Status](https://coveralls.io/repos/NavJobs/Transmit/badge.svg?branch=master&service=github)](https://coveralls.io/github/NavJobs/Transmit?branch=master)
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/NavJobs/Transmit/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/NavJobs/Transmit/?branch=master)
[![Latest Stable Version](https://poser.pugx.org/navjobs/transmit/v/stable)](https://packagist.org/packages/navjobs/transmit) [![Total Downloads](https://poser.pugx.org/navjobs/transmit/downloads)](https://packagist.org/packages/navjobs/transmit) [![License](https://poser.pugx.org/navjobs/transmit/license)](https://packagist.org/packages/navjobs/transmit)

###### Communication Layer For Laravel
Transmit was created to expedite the process of implementing REST APIs.

#### Install

Via Composer:
``` bash
$ composer require NavJobs/Transmit
```

Register the service provider in your config/app.php:

```php
'providers' => [
    ...
    NavJobs\Transmit\TransmitServiceProvider::class,
];
```

The package has a publishable config file that allows you to chang the default serializer. To publish:

```bash
php artisan vendor:publish --provider="NavJobs\Transmit\TransmitServiceProvider"
```

#### Api
Transmit provides an abstract controller class that you should extend from:

```php
use NavJobs\Transmit\Controller as ApiController;

class BookController extends ApiController
{
...
```

The controller class provides a number of methods that make API responses easy:

```php
//Return the specified item, transformed
$this->respondWithItem($item, $optionalTransformer);

//Sets the status code to 201 and return the specified item, transformed
$this->responsdWithItemCreated($item, $optionalTransformer);

//Return the specified collection, transformed
$this->respondWithCollection($collection, $optionalTransformer);

//Paginate the specified collection
$this->respondWithPaginatedCollection($collection, $optionalTransformer, $perPage = 10);

//Set the status code to 204, and return no content
$this->respondWithNoContent();
```

Also provided are a number of error methods. These return an error response as well as setting the status code:

```php
//Sets the status code to 403
$this->errorForbidden($optionalMessage);

//Sets the status code to 500
$this->errorInternalError($optionalMessage);

//Sets the status code to 404<commit_msg>fixing typo in readme<commit_after>[![Circle CI](https://circleci.com/gh/navjobs/transmit.svg?style=shield)](https://circleci.com/gh/navjobs/transmit)
[![Coverage Status](https://coveralls.io/repos/NavJobs/Transmit/badge.svg?branch=master&service=github)](https://coveralls.io/github/NavJobs/Transmit?branch=master)
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/NavJobs/Transmit/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/NavJobs/Transmit/?branch=master)
[![Latest Stable Version](https://poser.pugx.org/navjobs/transmit/v/stable)](https://packagist.org/packages/navjobs/transmit) [![Total Downloads](https://poser.pugx.org/navjobs/transmit/downloads)](https://packagist.org/packages/navjobs/transmit) [![License](https://poser.pugx.org/navjobs/transmit/license)](https://packagist.org/packages/navjobs/transmit)

###### Communication Layer For Laravel
Transmit was created to expedite the process of implementing REST APIs.

#### Install

Via Composer:
``` bash
$ composer require NavJobs/Transmit
```

Register the service provider in your config/app.php:

```php
'providers' => [
    ...
    NavJobs\Transmit\TransmitServiceProvider::class,
];
```

The package has a publishable config file that allows you to chang the default serializer. To publish:

```bash
php artisan vendor:publish --provider="NavJobs\Transmit\TransmitServiceProvider"
```

#### Api
Transmit provides an abstract controller class that you should extend from:

```php
use NavJobs\Transmit\Controller as ApiController;

class BookController extends ApiController
{
...
```

The controller class provides a number of methods that make API responses easy:

```php
//Return the specified item, transformed
$this->respondWithItem($item, $optionalTransformer);

//Sets the status code to 201 and return the specified item, transformed
$this->respondWithItemCreated($item, $optionalTransformer);

//Return the specified collection, transformed
$this->respondWithCollection($collection, $optionalTransformer);

//Paginate the specified collection
$this->respondWithPaginatedCollection($collection, $optionalTransformer, $perPage = 10);

//Set the status code to 204, and return no content
$this->respondWithNoContent();
```

Also provided are a number of error methods. These return an error response as well as setting the status code:

```php
//Sets the status code to 403
$this->errorForbidden($optionalMessage);

//Sets the status code to 500
$this->errorInternalError($optionalMessage);

//Sets the status code to 404
{'fraction_non_alphanumeric': 0.13335979360984324, 'fraction_numerical': 0.006747370510021829, 'mean_word_length': 5.904109589041096, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 19, 'https://': 24, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1235843', 'n_tokens_mistral': 1572, 'n_tokens_neox': 1469, 'n_words': 382}