PHPackages                             kaue-f/laravel-structura - 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. [Caching](/categories/caching)
4. /
5. kaue-f/laravel-structura

ActiveLibrary[Caching](/categories/caching)

kaue-f/laravel-structura
========================

Laravel-Structura is a tool designed to streamline and standardize the creation of resources in Laravel, promoting a more organized and scalable development structure.

v4.2.1(2mo ago)485MITPHPPHP ^8.2

Since Apr 14Pushed 2mo ago1 watchersCompare

[ Source](https://github.com/kaue-f/laravel-structura)[ Packagist](https://packagist.org/packages/kaue-f/laravel-structura)[ Docs](https://github.com/kaue-f/laravel-structura)[ RSS](/packages/kaue-f-laravel-structura/feed)WikiDiscussions main Synced today

READMEChangelog (10)Dependencies (7)Versions (16)Used By (0)

 English | [🇧🇷 Português](./docs/README_pt-BR.md)

Laravel Structura
=================

[](#laravel-structura)

> **Structura** comes from Latin and means structure and organization, reflecting the package's purpose.

🌟 Introduction
--------------

[](#-introduction)

**Laravel Structura** is a Laravel package designed to simplify, standardize, and structure the creation of application resources, promoting a clean, scalable, and well-organized development environment.

Through custom Artisan commands, the package enables the automatic generation of classes such as `Actions`, `Cache`, `DTOs`, `Enums`, `Helpers`, `Services` and `Traits`, encouraging clear separation of responsibilities and solid architectural best practices.

The main goal of Structura is to reduce repetitive tasks, ensure structural consistency, and help developers keep Laravel projects well-organized as they grow.

✨ Features
----------

[](#-features)

- ✅ **Action** generation with Makeable &amp; Transaction support
- ✅ **Cache** generation with CacheSupport extension
- ✅ **DTO** generation with readonly/final patterns
- ✅ **Enum** generation with PHP Attributes and `toData()` mapping
- ✅ **Helper** generation with global autoload registration
- ✅ **Trait** generation
- ✅ **Service** generation with ServiceResult and Makeable support
- ✅ Automatic namespace organization
- ✅ Consistent architectural patterns
- ✅ Centralized configuration via the `config/structura.php` file
- ✅ CLI options override default configuration
- ✅ Automatic suffix enforcement per class type

🛠 Requirements
--------------

[](#-requirements)

- PHP **^8.2**
- Laravel **^10.x | ^11.x | ^12.x**

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

[](#-installation)

```
composer require kaue-f/laravel-structura --dev
```

### ⚙️ Publishing the configuration file

[](#️-publishing-the-configuration-file)

```
php artisan structura:install
php artisan structura:install --force   # Force overwrite
```

This command creates a new `structura.php` file in the Laravel application's `config` directory. It controls namespaces, paths, suffixes, and default options for each generator.

### 🚀 AI Integration (Laravel Boost)

[](#-ai-integration-laravel-boost)

This package ships with a built-in [Laravel Boost](https://laravel.com/docs/boost) skill. If your project uses Boost, the Structura skill is automatically discovered and installed when you run:

```
php artisan boost:install
```

Once installed, your AI agent will understand the Structura architecture — Actions, Services, DTOs, Enums, Caches, and Helpers — and follow all naming conventions and patterns automatically.

📌 Available commands
--------------------

[](#-available-commands)

CommandDescription`structura:action`Create **Action** classes with Makeable &amp; Transaction support`structura:cache`Create **Cache** classes with optional CacheSupport`structura:dto`Create **Data Transfer Object (DTO)** classes`structura:enum`Create **Enum** classes with PHP Attribute mapping`structura:helper`Create **Helper** classes or global helpers`structura:service`Create **Service** classes with Result &amp; Makeable`structura:trait`Create **Trait** classes`structura:install`Publish Structura configuration file### 📚 Usage examples

[](#-usage-examples)

#### Action

[](#action)

```
php artisan structura:action Logout
php artisan structura:action Logout --execute     # Default (-e): generates execute() method
php artisan structura:action Logout --handle      # (-l): generates handle() method
php artisan structura:action Logout --invokable   # (-i): generates __invoke() method
php artisan structura:action Logout --construct   # (-c): generates __construct() method
php artisan structura:action Logout --makeable    # (-m): attaches Makeable trait → LogoutAction::run()
php artisan structura:action Logout --transaction # (-t): wraps method body in DB::transaction()
php artisan structura:action Logout --raw         # (-r): creates empty class body
```

> **Default method:** `execute()`. Override with `--handle`, `--invokable`, or `--construct`.
>
> **Pro Tip:** By default, `makeable` is `true` in `config/structura.php` — every new Action is ready for `LogoutAction::run()` usage out of the box!

#### Cache

[](#cache)

```
php artisan structura:cache Classification
php artisan structura:cache Classification --extend  # (-e): extends CacheSupport, adds $prefix property
php artisan structura:cache Classification --raw     # (-r): standalone class without CacheSupport
```

> Use `--extend` to inherit helper methods from `CacheSupport` (e.g., `remember()`, `forget()`). `--raw` creates a plain class. `--extend` and `--raw` are mutually exclusive.

#### DTO

[](#dto)

```
php artisan structura:dto User
php artisan structura:dto User --no-final         # Removes the final modifier
php artisan structura:dto User --no-readonly      # Removes the readonly modifier
php artisan structura:dto User --no-construct     # Removes the __construct method
php artisan structura:dto User --trait            # (-t): attaches InteractsWithDTO trait
php artisan structura:dto User --raw              # (-r): plain class, no modifiers or helpers
```

> DTOs are `final readonly` by default following PHP 8.2 best practices. Attach `--trait` to unlock `MyDTO::fromRequest($request)` and `MyDTO::fromArray($data)` helpers. `--raw` cannot be combined with other flags.

#### Enum

[](#enum)

```
php artisan structura:enum Status
php artisan structura:enum Status --backed=string              # Backed enum (string|int)
php artisan structura:enum Status --backed=string --cases=ACTIVE,INACTIVE  # Pre-generates cases
php artisan structura:enum Status --label                      # (-l): adds #[Label] attribute to each case
php artisan structura:enum Status --trait                      # (-t): attaches InteractsWithEnum trait
```

> **Modern Enum Usage:** Use `toData()` for powerful frontend integration:
>
> ```
> Status::toData();                                              // Minimalist: ['id' => '...', 'name' => '...']
> Status::toData(color: true, icon: true);                       // Includes color and icon attributes
> Status::toData(map: ['value' => 'id', 'label' => 'name']);    // Custom key renaming
> Status::toData(map: ['extra' => fn($case) => $case->extra()]); // Closure resolution
> ```
>
>
>
> The `InteractsWithEnum` trait adds `tryFromDefault()` fallback support. `#[Label]`, `#[Color]`, `#[Icon]`, and `#[DefaultCase]` Attributes are supported.

#### Helper

[](#helper)

```
php artisan structura:helper StringHelper
php artisan structura:helper StringHelper --example  # (-e): generates example method
php artisan structura:helper StringHelper --global   # (-g): creates global helpers.php and auto-registers it in composer.json autoload.files + runs dump-autoload
php artisan structura:helper --stub                  # (-s): creates helper from the package's own stub
```

> The `--global` flag automatically updates `composer.json` and runs `composer dump-autoload` so your global functions are immediately available.

#### Service

[](#service)

```
php artisan structura:service Comment
php artisan structura:service Comment --construct              # (-c): adds __construct() method
php artisan structura:service Comment --method=process         # (--m): generates a custom named method
php artisan structura:service Comment --result                 # (--res): method returns ServiceResult
php artisan structura:service Comment --makeable               # (--mk): attaches Makeable trait
```

> **ServiceResult** standardizes your service responses:
>
> ```
> return ServiceResult::success($data);
> return ServiceResult::failure('Error message');
> ```
>
>
>
> **Smart Generation:** Combining `--method=process` with `--makeable` automatically injects `protected string $makeableMethod = 'process'` so `CommentService::run()` dispatches to the right method instantly.

#### Trait

[](#trait)

```
php artisan structura:trait Loggable
```

> Traits do **not** receive automatic suffixes (unlike Actions, Services, etc.). So `structura:trait Loggable` generates `Loggable.php`, not `LoggableTrait.php`.

### ⚙️ Default Configuration (`config/structura.php`)

[](#️-default-configuration-configstructuraphp)

After publishing, you can set package-wide defaults in `config/structura.php`:

```
'default_options' => [
    'action' => [
        'execute'     => true,   // Default method
        'makeable'    => true,   // All new actions get Makeable trait by default
        'transaction' => false,
    ],
    'service' => [
        'makeable' => false,
        'result'   => false,
    ],
    'dto' => [
        'no-final'    => false,
        'no-readonly' => false,
    ],
    'enum' => [
        'backed' => 'string', // Default backing type: 'string' | 'int' | null
    ],
    // ...
],
```

> CLI flags always override config defaults.

### 🧱 Example Structure

[](#-example-structure)

```
app/
├── Actions/
│   └── LogoutAction.php
│
├── Caches/
│   └── ClassificationCache.php
│
├── Concerns/
│   └── Loggable.php
│
├── DTOs/
│   └── UserDTO.php
│
├── Enums/
│   └── StatusEnum.php
│
├── Helpers/
│   ├── helpers.php
│   ├── StringHelper.php
│   └── string_helper.php
│
├── Services/
│   └── CommentService.php

```

📄 License
---------

[](#-license)

Released under the [MIT License](LICENSE.md).

###  Health Score

44

—

FairBetter than 90% of packages

Maintenance84

Actively maintained with recent releases

Popularity15

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

 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 ~28 days

Recently: every ~1 days

Total

14

Last Release

83d ago

Major Versions

v1.5.0 → v2.0.02026-01-12

v2.0.0 → v3.0.02026-04-03

v3.0.0 → v4.0.02026-04-08

### Community

Maintainers

![](https://www.gravatar.com/avatar/b81fee069303741e5d2a85243c0da8a250d165fc61f9dea8a43824d5eee49d01?d=identicon)[kaue-f](/maintainers/kaue-f)

---

Top Contributors

[![kaue-f](https://avatars.githubusercontent.com/u/90930907?v=4)](https://github.com/kaue-f "kaue-f (29 commits)")

---

Tags

laravellaravel-packagelivewirepackagephp-librarylaravelpackageartisancacheserviceactionstructura

###  Code Quality

TestsPHPUnit

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/kaue-f-laravel-structura/health.svg)

```
[![Health](https://phpackages.com/badges/kaue-f-laravel-structura/health.svg)](https://phpackages.com/packages/kaue-f-laravel-structura)
```

###  Alternatives

[spatie/laravel-responsecache

Speed up a Laravel application by caching the entire response

2.8k9.0M69](/packages/spatie-laravel-responsecache)[awssat/laravel-visits

Laravel Redis visits counter for Eloquent models

973172.3k2](/packages/awssat-laravel-visits)[nexxai/laravel-cfcache

A handful of Cloudflare cache helpers for Laravel

13314.7k](/packages/nexxai-laravel-cfcache)[dragon-code/laravel-cache

An improved interface for working with cache

7046.0k10](/packages/dragon-code-laravel-cache)

PHPackages © 2026

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