Modular architecture for Laravel applications

Maintainers

Package info

github.com/HassanElZarkawy/origin

pkg:composer/hassanelzarkawy/origin

Statistics

Installs: 1

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

0.0.1 2026-05-31 13:11 UTC

This package is auto-updated.

Last update: 2026-05-31 13:18:10 UTC


README

Origin is a Laravel package that brings modular architecture to your application. It provides convention-based auto-discovery of routes, migrations, views, translations, config, commands, and factories — with zero boilerplate per module.

Requirements

  • PHP 8.2+
  • Laravel 11.x, 12.x, or 13.x

Installation

composer require hassanelzarkawy/origin

Laravel's package auto-discovery registers the service provider automatically. No manual configuration needed.

Publish the config file:

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

Quick Start

# Create your first module
php artisan make:module Blog

# Install module dependencies (each module has its own composer.json)
composer update

# Generate module components
php artisan make:module:model Blog Post --migration
php artisan make:module:controller Blog PostController
php artisan make:module:seeder Blog PostSeeder

# Run module migrations
php artisan module:migrate Blog

# Check module status
php artisan module:status

Documentation

Page Description
Configuration All config options and what they do
Creating Modules Module structure, make commands, and conventions
Auto-Discovery How routes, migrations, views, etc. are wired automatically
Console Commands Complete reference for all artisan commands
Module Load Ordering Priority and dependency-based module ordering
Enabling & Disabling Modules Toggle modules on and off
Publishing Module Assets Publish views, config, and translations
Removing Modules Clean removal of modules
Facade & API Reference Programmatic usage via the Modular facade
Testing Testing your modules

How It Works

Origin uses wikimedia/composer-merge-plugin to integrate modules with Composer. Each module gets its own composer.json, and the merge plugin automatically includes modules/*/composer.json when you run composer update.

On every request, Laravel boots the Origin\ModularServiceProvider. This provider:

  1. Scans the modules/ directory for module directories
  2. Filters out any disabled modules
  3. Resolves the correct load order (respecting priority and dependencies)
  4. Registers each module's ServiceProvider with Laravel

Each module's ServiceProvider extends Origin\ModuleServiceProvider, which auto-discovers and registers:

  • Routesroutes/web.php and routes/api.php
  • Migrationsdatabase/migrations/
  • Viewsresources/views/ (namespaced as {module}::)
  • Translationsresources/lang/
  • Configconfig/*.php
  • CommandsCommands/
  • Factoriesdatabase/factories/

Everything is convention-based. If the file or directory exists, it's registered. If it doesn't, it's silently skipped.

Module Directory Structure

modules/Blog/
├── Commands/                    # Auto-registered artisan commands
├── Controllers/                 # Module controllers
├── Models/                      # Eloquent models
├── Providers/
│   └── BlogServiceProvider.php  # Extends Origin\ModuleServiceProvider
├── routes/
│   ├── web.php                  # Web routes
│   └── api.php                  # API routes
├── database/
│   ├── migrations/              # Module migrations
│   ├── seeders/                 # Module seeders
│   └── factories/               # Model factories
├── resources/
│   ├── views/                   # Blade views (use as blog::*)
│   └── lang/                    # Translation files
├── config/                      # Module config files
└── composer.json                # Module dependencies (merged by composer-merge-plugin)

License

MIT