teepluss/hmvc

2.0.0 2015-03-05 08:41 UTC

This package is not auto-updated.

Last update: 2024-09-14 14:50:24 UTC


README

对于Laravel 4,请使用v1.x分支

HMVC是一个用于内部请求的工具。

安装

要在您的composer.json文件中获取HMVC的最新版本,只需要求它即可。

"teepluss/hmvc": "dev-master"

然后您需要运行composer install来下载它并更新自动加载器。

一旦安装了HMVC,您需要将服务提供者与应用程序注册。打开config/app.php并找到providers键。

'providers' => array(

    'Teepluss\Hmvc\HmvcServiceProvider'

)

HMVC还包含一个门面,提供了创建集合的静态语法。您可以在config/app.php文件的aliases键中注册门面。

'aliases' => [

    'HMVC' => 'Teepluss\Hmvc\Facades\HMVC',

]

使用方法

HMVC帮助您处理内部请求。

内部测试请求。

// GET Request.
HMVC::get('user/1');

// POST Request.
HMVC::post('user', array('title' => 'Demo'));

// PATCH Request.
HMVC::patch('user/1', array('title' => 'Changed'));

// PUT Request.
HMVC::put('user/1', array('title' => 'Changed'));

// DELETE Request.
HMVC::delete('user/1');

// Internal request with domain route.
HMVC::invoke('/someinternalpath', 'post', array('param' => 1))

// You can make remote request without changing code also.
HMVC::post('http://api.github.com', array('username' => 'teepluss'));

// Request remote with invokeRemote.
HMVC::invokeRemote('http://api.github.com', 'post', array('username' => 'teepluss'));

// Configure remote client.
$config = array('auth' => array('admin', 'admin'));
echo HMVC::configureRemoteClient($config)->get('http://127.0.0.1:9200');

// Get Guzzle to use other features.
$guzzle = HMVC::getRemoteClient();

使用Guzzle作为适配器的远程请求。

支持或联系

如果您有任何问题,请联系teepluss@gmail.com

Support via PayPal