structuraphp/structura-laravel

Laravel extension for Structura - Architectural testing stubs for Laravel applications

Maintainers

Package info

github.com/structuraphp/structura-laravel

pkg:composer/structuraphp/structura-laravel

Statistics

Installs: 1

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

dev-main 2026-05-24 14:48 UTC

This package is not auto-updated.

Last update: 2026-05-24 18:00:31 UTC


README

Structura Logo

Laravel extension for Structura — Install pre-configured architecture test stubs for your Laravel application.

Installation

composer require --dev structuraphp/structura-laravel

The service provider is auto-discovered by Laravel.

Usage

Initialize architecture tests

php artisan structura:init

This command will:

  1. Create the structura.php config file at the root of your project (if it doesn't exist)
  2. Prompt a multi-select to choose which architecture test stubs to install
  3. Generate the selected test files in tests/Architecture/

Run Structura commands

The structura command is a pass-through to the native StructuraPHP CLI:

# Run architecture analysis (default)
php artisan structura

# Explicit analyze
php artisan structura analyze

# With options
php artisan structura analyze --test-suite=laravel --stop-on-failure

# Other commands
php artisan structura init
php artisan structura make:test

Configuration

Publish the config file to customize paths and namespaces:

php artisan vendor:publish --tag=structura-config

This creates config/structura.php:

return [
    // Output directory for generated test files
    'output_dir' => 'tests/Architecture',

    // Namespace for generated test classes
    'output_namespace' => 'Tests\\Architecture',

    // Source paths per category
    'paths' => [
        'controller'   => 'app/Http/Controllers',
        'dto'          => 'app/DataTransferObjects',
        'event'        => 'app/Events',
        'factory'      => 'database/factories',
        'form_request' => 'app/Http/Requests',
        'job'          => 'app/Jobs',
        'listener'     => 'app/Listeners',
        'mail'         => 'app/Mail',
        'middleware'    => 'app/Http/Middleware',
        'model'        => 'app/Models',
        'notification' => 'app/Notifications',
        'policy'       => 'app/Policies',
        'route'        => 'routes',
        'service'      => 'app/Services',
    ],
];

Requirements

Dependency Version
PHP >= 8.2
Laravel 11.x / 12.x / 13.x
Structura >= 0.7