2017 © Pedro Peláez
 

yii2-extension yii2-jsend-response

Small set of tools to help work with JSend specifications (see https://labs.omniti.com/labs/jsend). Package is done for yii2 framework and yii2-oauth2-server. Package was build to simplify bilding response for API using this tools.

image

the-real-start/yii2-jsend-response

Small set of tools to help work with JSend specifications (see https://labs.omniti.com/labs/jsend). Package is done for yii2 framework and yii2-oauth2-server. Package was build to simplify bilding response for API using this tools.

  • Wednesday, August 24, 2016
  • by the-real-start
  • Repository
  • 1 Watchers
  • 0 Stars
  • 7 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 6 Versions
  • 0 % Grown

The README.md

Описание

Генерация ответов сервера в формате JSend (see https://labs.omniti.com/labs/jsend). Package содержит следующие классы:, (*1)

TRS\RestResponse\interfaces

TemplateInterface, (*2)

TRS\RestResponse\templates

BaseTemplate, (*3)

TRS\RestResponse\jsend

Response, (*4)

Пример


// your template class // templates needs for formating data section in response (remove some data for example) use TRS\RestResponse\templates\BaseTemplate class ProductSmallTemplate extends BaseTemplate { protected function prepareResult() { $this->result = [ 'id' => $this->model->id, 'title' => $this->model->title, 'description' => $this->model->description, // exclude other fields (prices, discounts etc.) ]; } } // model class Product extends BaseProduct { // you can use any other method name public function getAsArray($template = 'small') { if ($template == 'small') { $template = new ProductSmallTemplate($this); } else { throw new \InvalidArgumentException('Invalid template "' . $template . '"'); } return [ 'Product' => $template->getAsArray() ]; } } // controller use TRS\RestResponse\jsend\Response class ProductsController extends BaseController { public function actionShow($id) { $product = Product::find()->localized()->andWhere(['id' => $id])->one(); Response::success($product->getAsArray('small'))->send(); } }

Установка

Для того чтобы установить пакет через composer необходимо в вашем composer.json указать дополнительный источник (так как данный пакет не лежит в открытом доступе), и указать сам пакет., (*5)

...
"require": {
...
    "the-real-start/yii2-jsend-response": "*"
}
...

Или установить через консоль:, (*6)

composer require the-real-start/yii2-jsend-response

После установки все классы расширения доступны по namespace-у TRS\RestResponse., (*7)

Документация

Код по возможности был хорошо задокументирован и позволяет сформировать читабельный phpdoc., (*8)

Вкратце опишу как сгенерировать документацию., (*9)

Генерация phpdoc

Комманда для геренации документации по коду:, (*10)

phpdoc run -d ./ -t doc/ -i vendor/

The Versions

24/08 2016

dev-master

9999999-dev https://github.com/TheRealStart/yii2-jsend-response

Small set of tools to help work with JSend specifications (see https://labs.omniti.com/labs/jsend). Package is done for yii2 framework and yii2-oauth2-server. Package was build to simplify bilding response for API using this tools.

  Sources   Download

MIT

The Requires

 

by Avatar alegz

extension yii jsend

24/08 2016

v0.1.4

0.1.4.0 https://github.com/TheRealStart/yii2-jsend-response

Small set of tools to help work with JSend specifications (see https://labs.omniti.com/labs/jsend). Package is done for yii2 framework and yii2-oauth2-server. Package was build to simplify bilding response for API using this tools.

  Sources   Download

MIT

The Requires

 

by Avatar alegz

extension yii jsend

23/08 2016

v0.1.3

0.1.3.0 https://github.com/TheRealStart/yii2-jsend-response

Small set of tools to help work with JSend specifications (see https://labs.omniti.com/labs/jsend). Package is done for yii2 framework and yii2-oauth2-server. Package was build to simplify bilding response for API using this tools.

  Sources   Download

MIT

The Requires

 

by Avatar alegz

extension yii jsend

02/06 2016

0.1.2

0.1.2.0

REST Response

  Sources   Download

MIT

The Requires

 

by Avatar alegz

23/05 2016

0.1.1

0.1.1.0

REST Response

  Sources   Download

MIT

The Requires

 

by Avatar alegz

19/05 2016

0.1.0

0.1.0.0

REST Response

  Sources   Download

MIT

The Requires

 

by Avatar alegz