PHPackages                             futuretek/yii2-api - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. futuretek/yii2-api

ActiveYii2-extension[API Development](/categories/api)

futuretek/yii2-api
==================

API used in FTS.

2.1.1(3y ago)0202Apache-2.0PHPPHP &gt;=7.4.0

Since Oct 31Pushed 3y ago1 watchersCompare

[ Source](https://github.com/futuretek-solutions-ltd/yii2-ext-api)[ Packagist](https://packagist.org/packages/futuretek/yii2-api)[ Docs](https://www.futuretek.cz/)[ RSS](/packages/futuretek-yii2-api/feed)WikiDiscussions master Synced today

READMEChangelog (3)Dependencies (3)Versions (9)Used By (0)

ext-api
=======

[](#ext-api)

Yii2 JSON API.

Requirements
------------

[](#requirements)

- Yii2
- ext-shared-components

Installation
------------

[](#installation)

Use composer and add the following line to your composer.json file:

```
"futuretek/yii2-api": "*"

```

Changelog
---------

[](#changelog)

### v1.0.0

[](#v100)

- Initial release

Usage
-----

[](#usage)

Setup the API in the init method of your controller:

```
	public function init()
	{
		$this->setIdentity(UserModel);
		parent::init();
	}
```

Define the custom actions:

```
public function actions()
{
    return [
        ...,
        'myAction' => [
            'class' => 'futuretek\api\ApiAction',
        ],
        ...,
    ];
}
```

Add phpDoc tags (see below) to the properly documented actions you want:

```
/**
* Returns hello and the name that you gave
*
* @param string $name Your name
* @return string
* @api
*/
public function getHello($name)
{
    return ['hello' => 'Hello ' . $name];
}
```

Optionaly use IpFilter to limit access to API. Declare it in the `behaviors()` method of your controller class.

```
public function behaviors()
{
    return [
        'ips' => [
            'class' => \futuretek\api\IpFilter::className(),
            'policy' => IpFilter::POLICY_ALLOW_ALL,
            'list' => [
                '192.168.1.2',
                '192.168.11.1-192.168.11.27',
                '10.*.*.*',
                '172.16.1.0/24',
            ],
        ],
    ];
}
```

Built-in methods
----------------

[](#built-in-methods)

### ping

[](#ping)

Ping action intended mainly to test the API interface availability

### generate-definition

[](#generate-definition)

Generate API methods definition list

This is the default action if API method is not specified

### generate-confluence-documentation

[](#generate-confluence-documentation)

Generate API documentation in Confluence markup

Allowed phpDoc tags
-------------------

[](#allowed-phpdoc-tags)

### @param

[](#param)

Usage: `@param type $variable description {additional parameters}`

Indicate input variable. If the input variable is an array, you can define it by using \[\], eg. String\[\]

#### Additional parameters

[](#additional-parameters)

Optionally, extra attributes can be defined for each @param tag by enclosing definitions into curly brackets and separated by comma like so:

`{[attribute1 = value1][, attribute2 = value2], ...}`

where the attribute can be one of following:

**validate** - Specifies validator function to check parameter value against

Validator must be static method name from the Validate class.

- isInt
- isString

**element** - Array element definition. If @param is of type Array, you can describe array elements with this attribute

Usage: `{element=name|type|description, element=name|type, ...}`

### @return

[](#return)

Usage: `@return type description`

Indicate method return value. If the return value is an array, you can define it by using \[\], eg. String\[\]

**Remember:** API function should always (and I mean ALWAYS!) return associative array. If another type is returned, it will be treated like the function has no output. Additionally if the function returns boolean false (or another data type that can be typed to false), the API call will result in general error message.

If you want to express processing fail inside the method, you should throw an exception.

### @return-param

[](#return-param)

Usage: `@return-param type name description`

All API methods must return Array, bool or void(null). In case of Array you can specify each array element with this tag. This is mainly to describe the method. No additional logic is bind to this tag.

### @api

[](#api)

Usage: `@api`

Indicates that this method should be accessible via API interface. Methods without this tag are ignored.

### @no-auth

[](#no-auth)

Usage: `@no-auth`

Indicates that this method will be publicly accessible without user identification

### @permission

[](#permission)

Usage: `@permission permissionName`

Require specified RBAC permission to run action. If @no-auth is used, this tag will be ignored

### @transaction

[](#transaction)

Usage: `@transaction`

Run method in database transaction

###  Health Score

30

—

LowBetter than 62% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity68

Established project with proven stability

 Bus Factor1

Top contributor holds 87.7% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~318 days

Recently: every ~84 days

Total

8

Last Release

1302d ago

Major Versions

1.1.0 → 2.0.02022-01-05

PHP version history (2 changes)1.0.0PHP &gt;=5.4.0

2.0.0PHP &gt;=7.4.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/1ce67c863775f4dd7237db0547fe39aaf85c9841f34773d67e88f62dcf948ae4?d=identicon)[futuretek](/maintainers/futuretek)

---

Top Contributors

[![lukascernydis](https://avatars.githubusercontent.com/u/3111717?v=4)](https://github.com/lukascernydis "lukascernydis (50 commits)")[![petrleocompel](https://avatars.githubusercontent.com/u/9423543?v=4)](https://github.com/petrleocompel "petrleocompel (7 commits)")

---

Tags

jsonapiextensionyii

### Embed Badge

![Health badge](/badges/futuretek-yii2-api/health.svg)

```
[![Health](https://phpackages.com/badges/futuretek-yii2-api/health.svg)](https://phpackages.com/packages/futuretek-yii2-api)
```

###  Alternatives

[aimeos/ai-client-jsonapi

Aimeos frontend JSON REST API

1.0k333.9k16](/packages/aimeos-ai-client-jsonapi)[mikemadisonweb/yii2-elasticsearch

Yii2 extension for integration with Elasticsearch version 5.0 and above.

164.1k](/packages/mikemadisonweb-yii2-elasticsearch)[skeeks/yii2-google-api

Component for work with google api based on google/apiclient

1143.8k1](/packages/skeeks-yii2-google-api)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
