New:Introducing Socket Scanning for VS Code Marketplace Extensions.Learn more →
Get Started

ademes/core

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ademes/core

Ademes core service, developed by laravel 5.1

Source
Packagist
Version
1.0.0
Version published
Total downloads
259
Maintainers
1
Created
Source

Ademes Core Laravel 4 supported

Ademes Core modules

Should include all core modules and functions for different applications

Installation

Add the following line to the require section of composer.json:

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

Setup

  • 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

php artisan config:publish ademes/core

Afterwards edit the file app/config/packages/ademes/core/core.php to suit your needs.

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

  • 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.

Client has 3 methods:

  • GET
  • POST
  • 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.

Request Examples

  • GET
$query = $this->http->get($_ENV['API_VERSION'].'/companies', [
    'query' => [
        'access_token' => Session::get('AuthToken')->getAccessToken()
    ]
]);
  • 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);
  • DELETE
$body = ['access_token'=>Session::get('AuthToken')->getAccessToken()];
$response = $this->http->delete($_ENV['API_VERSION'] . '/companies/' . $id, ['body'=>$body]);
  • 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);

FAQs

Package last updated on 06 Aug 2015

Related posts