ademes/core 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

ademes/core

最新稳定版本:1.0.0

Composer 安装命令:

composer require ademes/core

包简介

README 文档

README

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

  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

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

  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.

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.

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);

统计信息

  • 总下载量: 259
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 2
  • Forks: 3
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-05-23