2017 © Pedro Peláez
 

library core

Ademes core service, developed by laravel 5.1

image

ademes/core

Ademes core service, developed by laravel 5.1

  • Friday, September 23, 2016
  • by lhj1982
  • Repository
  • 2 Watchers
  • 0 Stars
  • 243 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 3 Forks
  • 0 Open issues
  • 4 Versions
  • 0 % Grown

The README.md

Ademes Core modules

Should include all core modules and functions for different applications, (*1)

Installation

Add the following line to the require section of composer.json:, (*2)

{
    "require": {
        "ademes/core": "dev-master"
    }
}

Setup

  1. Add 'Ademes\Core\CoreServiceProvider', to the service provider list in app/config/app.php.

Configuration

In order to use the Api Proxy publish its configuration first, (*3)

php artisan config:publish ademes/core

Afterwards edit the file app/config/packages/ademes/core/core.php to suit your needs., (*4)

Usage

Authentication

$authResponse = $app['authClient']->authenticate('admin@admin.com', '000000', 'IhzopIc5SuMf3oUT', 'GUXaqBpeFgN1GKYNTOvh4nOnRpEig4J1');
if ($authResponse) {
    Session::set('AuthToken', $authResponse);
} else {
    throw new Exception('You\'re not authenticated');
}

Fetch User info

  1. Get logged in user
$user = $app['userClient']->getLoggedInUser($authResponse->getAccessToken());
if ($user) {
    Session::put('data.user', $user);
}

Http Client

Use this class for all request to api services., (*5)

Client has 3 methods: 1. GET 2. POST 3. DELETE Due to limitation of Laravel 4, to be able to make PUT, PATCH request, we have to sende '_method'=>'PUT'/'PATCH' in message body., (*6)

Request Examples

  1. GET
$query = $this->http->get($_ENV['API_VERSION'].'/companies', [
    'query' => [
        'access_token' => Session::get('AuthToken')->getAccessToken()
    ]
]);
  1. POST
$data = [
    'headers' => ['Content-Type' => 'application/x-www-form-urlencoded'],
    'body' => [
        'name' => Input::get('name'),
        'description' => Input::get('description'),
        'url' => Input::get('url'),
        'photo' => fopen($path, 'r'),
        'access_token' => Session::get('AuthToken')->getAccessToken()
    ]
];
$response = $this->http->post($_ENV['API_VERSION'] . '/companies', $data);
  1. DELETE
$body = ['access_token'=>Session::get('AuthToken')->getAccessToken()];
$response = $this->http->delete($_ENV['API_VERSION'] . '/companies/' . $id, ['body'=>$body]);
  1. PUT
$data = [
    'headers' => ['Content-Type' => 'application/x-www-form-urlencoded'],
    'body' => [
        '_method' => 'PUT',
        'name' => Input::get('name'),
        'description' => Input::get('description'),
        'url' => Input::get('url'),
        'access_token' => Session::get('AuthToken')->getAccessToken()
    ]
];
$response = $this->http->post($_ENV['API_VERSION'] . '/companies/'.$id, $data);

The Versions

23/09 2016

dev-release/2.0.0

dev-release/2.0.0

Ademes core service, developed by laravel 5.1

  Sources   Download

MIT

The Requires

 

by Huajun Li

06/08 2015

dev-release/1.0.0

dev-release/1.0.0

Ademes core service, developed by laravel 4

  Sources   Download

MIT

The Requires

 

by Huajun Li

06/08 2015

1.0.0

1.0.0.0

Ademes core service, developed by laravel 4

  Sources   Download

MIT

The Requires

 

by Huajun Li

02/08 2015

dev-master

9999999-dev

  Sources   Download

MIT

The Requires

 

by Huajun Li