PHPackages                             sakadigital/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. sakadigital/api

ActiveLibrary[API Development](/categories/api)

sakadigital/api
===============

Package for build Rest Api for your application

2.0.1(10y ago)656MITPHPPHP &gt;=5.4

Since Dec 17Pushed 10y ago4 watchersCompare

[ Source](https://github.com/sakadigital/api)[ Packagist](https://packagist.org/packages/sakadigital/api)[ RSS](/packages/sakadigital-api/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (6)DependenciesVersions (5)Used By (0)

Rest Api Structure for Laravel
==============================

[](#rest-api-structure-for-laravel)

Build Rest Api with laravel Php Framework. This package also genrate automaticly documentation for your API based Api controller docblock and test api function.

Features
--------

[](#features)

- Versioning API
- Enabled/Disabled API or Some version
- Enabled/Disabed Documentation
- Bypass csrf token laravel for api prefix
- Auto-generation of API documentation based on docblock
- Simulate API call &amp; view API return data

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

[](#installation)

Require this package with composer:

```
composer require sakadigital/api

```

After updating composer, add the ApiServiceProvider to the providers array in config/app.php

```
Sakadigital\Api\ApiServiceProvider::class,

```

and also add the facades

```
'Api' => Sakadigital\Api\Facades\Api::class,

```

Copy the package resource to your application with the publish command:

```
php artisan vendor:publish

```

by run command vendor:publish we will copy folder and file as following:

- Config file `api.php` to `/config` folder
- Asset folder `apidoc` to `/public` folder, this folder contain css,js, etc.
- Api structur `Api` folder to `/App`, this folder contain `Controllers` folder as a place for your api controller, and `routes.php` for api route.

And you are ready to build your API.

Using The Package
-----------------

[](#using-the-package)

If you finish installation process above, by default your api is active and now you can checkout your api by GET , and also documentation by GET .

### creating controller

[](#creating-controller)

Your controller is your documentation, so we sugest you to follow some our standard to make controller file for documentation page.

##### Class Name

[](#class-name)

- use prefix and suffix for contoller `Api`{{Object}}`Controller`, for example if you will use Auth you should use file and class name `ApiAuthContoller`,
- Add description to your calss.

```
/**
 * This is description from file ApiAuthController
*/
class ApiAuthController extends Controller {
    //...
}

```

##### Function

[](#function)

each function must have a description, param, return, and error. example:

```
    /**
	 * Login user from api
	 * This process will generate new token of loginned user
	 *
	 * @param email | registered user email with role | required email
	 * @param password | user password that created with role | required
	 * @return user_id | id of user
	 * @return user_token | user token for access data via api
	 * @return providers | list of connected providers
	 * @error Email or Password not match | no email and password registered in database
	 */
	public function login(Request $request)
	{
	    //...
	}

```

in `@param` contain information about paramter, description and validation rule that sparated by `|`, and in `@return` also contain return type or name and description of function return. `@error` is special error that function made, you can give the information to the error.

- Place your all controllers inside Api controllers folder.

### using versioning

[](#using-versioning)

if you will make your api with many version create folder inside you api namespace :

```
App
|_ Api
    |_ v1 //your first version here
        |_ Controllers
        |_ route.php
    |_ v2 //your second version
       |...

```

place your `routes.php` in each version and create `Controllers` folder in each version and place your contorller and register your api version bellow as following:

```
'version'=>[
    'v1'=> ['enabled'=>true, 'namespace'=>'App\Api\v1', 'prefix'=>'v1'],
    'v2'=> ['enabled'=>true, 'namespace'=>'App\Api\v2', 'prefix'=>'v2'],
],

```

your version prefix will placed in second url prefix [http://yourdomain.com/{api-prefix}/{version-prefix}/](http://yourdomain.com/%7Bapi-prefix%7D/%7Bversion-prefix%7D/)

### Routing

[](#routing)

this package will automaticly append prefix to routes as api config file

```
Route::get('test', function(){
    return response()->toJson('Hallo word!');
});

```

test by GET [http://yourdomian.com/api/`test](http://yourdomian.com/api/%60test)', if you use version v1, GET

###  Health Score

29

—

LowBetter than 57% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity13

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity61

Established project with proven stability

 Bus Factor1

Top contributor holds 93.8% 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 ~6 days

Total

5

Last Release

3822d ago

Major Versions

1.0.2 → 2.0.02016-01-12

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/15634842?v=4)[sakadigital](/maintainers/sakadigital)[@sakadigital](https://github.com/sakadigital)

---

Top Contributors

[![dedenmaulana](https://avatars.githubusercontent.com/u/4162864?v=4)](https://github.com/dedenmaulana "dedenmaulana (15 commits)")[![sakadigital](https://avatars.githubusercontent.com/u/15634842?v=4)](https://github.com/sakadigital "sakadigital (1 commits)")

---

Tags

apilaravelREST APIapi-documentation

### Embed Badge

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

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

###  Alternatives

[gdebrauwer/laravel-hateoas

Expose the authorization logic of your REST API using HATEOAS links on your Laravel API resources

17597.0k](/packages/gdebrauwer-laravel-hateoas)[shahghasiadil/laravel-api-versioning

Elegant attribute-based API versioning solution for Laravel applications with built-in deprecation management and version inheritance

2915.0k](/packages/shahghasiadil-laravel-api-versioning)

PHPackages © 2026

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