Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Laravel 5 #29

Open
wants to merge 22 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
language: php

php:
- 5.4
- 5.5
- 5.5.9

before_script:
- wget http://getcomposer.org/composer.phar
Expand Down
27 changes: 7 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,10 @@
# Trucker

[<img src="https://s3-us-west-2.amazonaws.com/oss-avatars/trucker.png"/>](http://indatus.com/company/careers)

[![Latest Stable Version](https://poser.pugx.org/indatus/trucker/v/stable.png)](https://packagist.org/packages/indatus/trucker) [![Total Downloads](https://poser.pugx.org/indatus/trucker/downloads.png)](https://packagist.org/packages/indatus/trucker) [![Build Status](https://travis-ci.org/Indatus/trucker.png?branch=master)](https://travis-ci.org/Indatus/trucker) [![Coverage Status](https://coveralls.io/repos/Indatus/trucker/badge.png?branch=master)](https://coveralls.io/r/Indatus/trucker?branch=master) [![Dependency Status](https://www.versioneye.com/user/projects/530271f4ec1375bab10004bb/badge.png)](https://www.versioneye.com/user/projects/530271f4ec1375bab10004bb)

Trucker is a PHP package for mapping remote API resources (usually RESTful) as models in an ActiveResource style. The benefit is easier use of remote APIs in a fast and clean programming interface.

<!--
<img align="left" height="300" src="https://s3-us-west-2.amazonaws.com/oss-avatars/trucker_round_readme.png">
-->


```php
<?php
Expand All @@ -35,7 +30,6 @@ $results = Product::all(); //find a collection
* [Requirements](#requirements)
* [Install With Composer](#install-composer)
* [Configure in Laravel](#config-laravel)
* [Configure outside Laravel](#config-non-laravel)
* [Configuration Options](#config)
* [Auth](#config-auth)
* [Error Handler](#config-error-handler)
Expand Down Expand Up @@ -67,45 +61,38 @@ $results = Product::all(); //find a collection
<a name="requirements"/>
### Requirements

- Any flavour of PHP 5.4+ should do
- Any flavour of PHP 5.5+ should do

<a name="install-composer"/>
### Install With Composer

You can install the library via [Composer](http://getcomposer.org) by adding the following line to the **require** block of your *composer.json* file:

````
"indatus/trucker": "dev-master"
"indatus/trucker": "dev-laravel-5"
````

> Note: This project will not be supported for future versions of Laravel. We do not recommend continuing to implement this package in Laravel projects, unless someone else would like to begin to maintain this project (create an issue if you are).

Next run `composer install`, now you need to publish the config files.

Trucker's config files are where you'd define constant things about the API your interacting with, like the end-point, what drivers you want to use etc.

<a name="config-laravel"/>
### Configure in Laravel

Trucker works well with the [Laravel](http://laravel.com) framework. If your using Trucker within Laravel, you just need to run the following command to publish the Trucker config files to the **app/config/packages/indatus/trucker** folder.
Trucker works well with the [Laravel](http://laravel.com) framework. If your using Trucker within Laravel, you just need to run the following command to publish the Trucker config files.

````
php artisan config:publish indatus/trucker
php artisan vendor:publish indatus/trucker
````

The final step is to add the service provider. Open `app/config/app.php`, and add a new item to the providers array.

'Trucker\TruckerServiceProvider'
'Trucker\TruckerServiceProvider::class'

Now you should be ready to go.

<a name="config-non-laravel"/>
### Configure outside Laravel

If your using Trucker outside Laravel you just need to create the `.trucker` folder in your project root and copy the package's config files there. Here's the *nix command for that.

````
mkdir .trucker && cp vendor/indatus/trucker/src/config/* .trucker/
````

<a name="config"/>
## Configuration Options

Expand Down
10 changes: 5 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@
}
],
"require": {
"php": ">=5.4.0",
"illuminate/support": "~4",
"illuminate/config": "~4",
"illuminate/container": "~4",
"php": ">=5.5.9",
"illuminate/support": "~5",
"illuminate/config": "~5",
"illuminate/container": "~5",
"guzzle/guzzle": "3.8.1",
"doctrine/inflector": "1.0",
"patchwork/utf8": "1.1.*"
"patchwork/utf8": "1.2.*"
},
"require-dev": {
"phpunit/phpunit": "4.1.*",
Expand Down
26 changes: 11 additions & 15 deletions src/Trucker/Factories/ApiTransporterFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,54 +10,50 @@
*/
namespace Trucker\Factories;

use Illuminate\Container\Container;
use Trucker\Framework\FactoryDriver;
use Trucker\Facades\Config;
use Trucker\Framework\FactoryDriver;

class ApiTransporterFactory extends FactoryDriver
{
/**
* Function to return a string representaion of the namespace
* Function to return a string representaion of the namespace
* that all classes built by the factory should be contained within
*
*
* @return string - namespace string
*/
public function getDriverNamespace()
{
return "\Trucker\Transporters";
}


/**
/**
* Function to return the interface that the driver's produced
* by the factory must implement
*
*
* @return string
*/
public function getDriverInterface()
{
return "\Trucker\Transporters\TransporterInterface";
}


/**
* Function to return a string that should be suffixed
* to the studly-cased driver name of all the drivers
* that the factory can return
*
* that the factory can return
*
* @return string
*/
public function getDriverNameSuffix()
{
return "Transporter";
}


/**
* Function to return a string that should be prefixed
* to the studly-cased driver name of all the drivers
* that the factory can return
*
*
* @return string
*/
public function getDriverNamePrefix()
Expand All @@ -68,7 +64,7 @@ public function getDriverNamePrefix()
/**
* Function to return an array of arguments that should be
* passed to the constructor of a new driver instance
*
*
* @return array
*/
public function getDriverArgumentsArray()
Expand All @@ -77,11 +73,11 @@ public function getDriverArgumentsArray()
}

/**
* Function to return the string representation of the driver
* Function to return the string representation of the driver
* itslef based on a value fetched from the config file. This
* function will itself access the config, and return the driver
* setting
*
*
* @return string
*/
public function getDriverConfigValue()
Expand Down
24 changes: 10 additions & 14 deletions src/Trucker/Factories/AuthFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,54 +10,50 @@
*/
namespace Trucker\Factories;

use Illuminate\Container\Container;
use Trucker\Framework\FactoryDriver;
use Trucker\Facades\Config;
use Trucker\Framework\FactoryDriver;

class AuthFactory extends FactoryDriver
{
/**
* Function to return a string representaion of the namespace
* Function to return a string representaion of the namespace
* that all classes built by the factory should be contained within
*
*
* @return string - namespace string
*/
public function getDriverNamespace()
{
return "\Trucker\Requests\Auth";
}


/**
* Function to return the interface that the driver's produced
* by the factory must implement
*
*
* @return string
*/
public function getDriverInterface()
{
return "\Trucker\Requests\Auth\AuthenticationInterface";
}


/**
* Function to return a string that should be suffixed
* to the studly-cased driver name of all the drivers
* that the factory can return
*
* that the factory can return
*
* @return string
*/
public function getDriverNameSuffix()
{
return "Authenticator";
}


/**
* Function to return a string that should be prefixed
* to the studly-cased driver name of all the drivers
* that the factory can return
*
*
* @return string
*/
public function getDriverNamePrefix()
Expand All @@ -68,7 +64,7 @@ public function getDriverNamePrefix()
/**
* Function to return an array of arguments that should be
* passed to the constructor of a new driver instance
*
*
* @return array
*/
public function getDriverArgumentsArray()
Expand All @@ -77,11 +73,11 @@ public function getDriverArgumentsArray()
}

/**
* Function to return the string representation of the driver
* Function to return the string representation of the driver
* itslef based on a value fetched from the config file. This
* function will itself access the config, and return the driver
* setting
*
*
* @return string
*/
public function getDriverConfigValue()
Expand Down
24 changes: 10 additions & 14 deletions src/Trucker/Factories/ErrorHandlerFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,54 +10,50 @@
*/
namespace Trucker\Factories;

use Illuminate\Container\Container;
use Trucker\Framework\FactoryDriver;
use Trucker\Facades\Config;
use Trucker\Framework\FactoryDriver;

class ErrorHandlerFactory extends FactoryDriver
{
/**
* Function to return a string representaion of the namespace
* Function to return a string representaion of the namespace
* that all classes built by the factory should be contained within
*
*
* @return string - namespace string
*/
public function getDriverNamespace()
{
return "\Trucker\Responses\ErrorHandlers";
}


/**
* Function to return the interface that the driver's produced
* by the factory must implement
*
*
* @return string
*/
public function getDriverInterface()
{
return "\Trucker\Responses\ErrorHandlers\ErrorHandlerInterface";
}


/**
* Function to return a string that should be suffixed
* to the studly-cased driver name of all the drivers
* that the factory can return
*
* that the factory can return
*
* @return string
*/
public function getDriverNameSuffix()
{
return "ErrorHandler";
}


/**
* Function to return a string that should be prefixed
* to the studly-cased driver name of all the drivers
* that the factory can return
*
*
* @return string
*/
public function getDriverNamePrefix()
Expand All @@ -68,7 +64,7 @@ public function getDriverNamePrefix()
/**
* Function to return an array of arguments that should be
* passed to the constructor of a new driver instance
*
*
* @return array
*/
public function getDriverArgumentsArray()
Expand All @@ -77,11 +73,11 @@ public function getDriverArgumentsArray()
}

/**
* Function to return the string representation of the driver
* Function to return the string representation of the driver
* itslef based on a value fetched from the config file. This
* function will itself access the config, and return the driver
* setting
*
*
* @return string
*/
public function getDriverConfigValue()
Expand Down
Loading