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

ActiveLibrary

zirvu/api
=========

Zirvu API

1.0.1(3mo ago)038PHPPHP ^8.2

Since Dec 6Pushed 3mo ago1 watchersCompare

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

READMEChangelogDependencies (1)Versions (18)Used By (0)

🚀 Zirvu Laravel Modular Service Package
=======================================

[](#-zirvu-laravel-modular-service-package)

📦 Installation
--------------

[](#-installation)

```
composer require zirvu/api
```

A flexible and scalable Laravel package built around a **modular service architecture**. It enables fast backend development by organizing logic into services, repositories, and models — making your code clean, dynamic, and easy to extend across any domain (e.g., user management, roles, settings, monitoring, etc.).

---

🧩 Key Features
--------------

[](#-key-features)

- 📦 Modular service-based structure
- 🧠 Dynamic service loading via trait (`loadUserService`, `loadMenuService`, etc.)
- 🔄 Built-in support for filtering, pagination, relationship loading
- 🔗 Safe model deletion through dynamic relationship checks
- 🧱 Standardized controller structure with consistent JSON responses
- ✅ Works across any domain: user, setting, HR, inventory, tracking...

---

⚙️ How to Use
-------------

[](#️-how-to-use)

### 1. 🧠 Load a Service

[](#1--load-a-service)

Use the `Zirvu\Api\Traits\Service` trait in your controller:

```
use Zirvu\Api\Traits\Service;

class ExampleController
{
    use Service;

    public function index()
    {
        $this->loadUserService(); // Dynamically loads UserService
        return $this->userService->get((object)[
            "filter" => "name:contains:admin"
        ]);
    }
}
```

> 🔧 Make sure the service is registered in `config/zirvu/api/classes.php` under the correct category.

---

### 2. 🧱 Use a Model with Smart Delete Check

[](#2--use-a-model-with-smart-delete-check)

Every model should use the `Relation` trait:

```
use Illuminate\Database\Eloquent\Model;
use Zirvu\Api\Traits\Relation;

class User extends Model
{
    use Relation;

    protected $fillable = ["name", "username", "password"];
}
```

#### 🔐 Why `Relation`?

[](#-why-relation)

When deleting a model, the repository checks if any child relations exist before allowing deletion:

```
if (!$model->checkDelete()) {
    // skip delete or throw validation error
}
```

Prevents accidental deletion of records that are still being referenced by other data.

---

### 3. 🧩 Common Service Methods

[](#3--common-service-methods)

#### 📄 `get(object $options)`

[](#-getobject-options)

```
$this->userService->get((object)[
    "filter" => "username:contains:admin",
    "take" => 10,
    "page" => 1,
    "with_roles" => 1
]);
```

- Supports filter operators: `=`, `!=`, `>`, `=`, `id ?? null;
$this->settingService->save($id, [
    "id" => $id,
    "key" => "site_name",
    "value" => "Zirvu CMS"
]);
```

#### 🗑️ `delete(array $ids)`

[](#️-deletearray-ids)

```
$this->userService->delete([1, 2]);
```

---

### 🧰 Standard JSON Controller Response

[](#-standard-json-controller-response)

Use the `CommonController` trait for consistent API output:

```
use Zirvu\Api\Traits\ControllerExtension\CommonController;

class UserController
{
    use CommonController;

    public function data(Request $request)
    {
        $this->loadUserService();
        $this->data = $this->userService->get((object)[
            "filter" => $request->filter ?? ""
        ]);
        return $this->response(200, true);
    }
}
```

📦 Auto response format:

```
{
  "success": true,
  "message": "Success!",
  "pagination": { ... },
  "data": [ ... ]
}
```

---

📁 Suggested Structure
---------------------

[](#-suggested-structure)

```
app/
├── Services/               # All business logic modules
├── Repositories/          # DB logic layer
├── Models/                # Use Relation trait
└── Http/Controllers/      # Use Service + CommonController traits

```

---

Built for extensibility and reusability across any Laravel project — modular, scalable, and production-ready.

> Made by Zirvu

###  Health Score

42

—

FairBetter than 90% of packages

Maintenance79

Regular maintenance activity

Popularity8

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity63

Established project with proven stability

 Bus Factor1

Top contributor holds 100% 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 ~49 days

Recently: every ~119 days

Total

17

Last Release

109d ago

Major Versions

0.0.15 → 1.0.02025-06-28

PHP version history (2 changes)0.0.0PHP ^7.3|^8.0

0.0.5PHP ^8.2

### Community

Maintainers

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

---

Top Contributors

[![zirvu](https://avatars.githubusercontent.com/u/93853818?v=4)](https://github.com/zirvu "zirvu (19 commits)")

---

Tags

laravel-api-service-modular-reusable-scalable

### Embed Badge

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

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

###  Alternatives

[fumeapp/modeltyper

Generate TypeScript interfaces from Laravel Models

196277.9k](/packages/fumeapp-modeltyper)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

245.2k](/packages/aedart-athenaeum)

PHPackages © 2026

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