Search by

mazdel / dayravel

mazdel

Laravel module scaffolding commands with automatic module route discovery.

Package info

github.com/mazdel/dayravel

pkg:composer/mazdel/dayravel

Statistics

Installs: 12

Dependents: 0

Suggesters: 0

Stars: 0

v1.0.5 2026-10-31 05:26 UTC

This package is not auto-updated.

Last update: 2026-10-31 05:27:32 UTC


README

A Laravel package for scaffolding modules and automatically loading their web and API route files.

Requirements

  • PHP 8.4+
  • Laravel 11, 12, or 13

Installation

composer require mazdel/dayravel

Laravel discovers the package service provider automatically. Publish the configuration before changing the module path or route groups:

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

This creates config/dayravel.php in your application.

Commands

Create a module

Create a module with both web and API routes:

php artisan module:init Catalog

Create an API-only or web-only module:

php artisan module:init Catalog --only-api
php artisan module:init Catalog --only-web

By default, a module is created in app/Modules/<ModuleName> with Controllers, Models, Validations, and Routes directories. Web modules also receive a views directory and an index.blade.php view. module:init creates a MainController automatically; use --only-api to create it from the API controller stub.

Generate module classes

All generators require an existing module name as their first argument.

# The controller name is optional and defaults to MainController.
php artisan module:make:controller Catalog ProductController
php artisan module:make:controller Catalog ProductController --api

php artisan module:make:model Catalog Product

php artisan module:make:request Catalog StoreProductRequest
php artisan module:make:request Catalog StoreProductRequest --api

php artisan module:make:validation Catalog ProductValidation
php artisan module:make:validation Catalog ProductValidation --api

php artisan module:make:middleware Catalog EnsureCatalogAccess
php artisan module:make:trait HasCatalog

The --api option selects the API stub for controllers, requests, and validations.

Routing and configuration

The package loads each module's Routes/web.php and Routes/api.php files beneath the configured modules path. Web routes use the configured web middleware; API routes use the configured prefix, route-name prefix, and API middleware.

The published config/dayravel.php file contains these defaults:

return [
    // The base directory in which modules are created and discovered.
    'modules_path' => app_path('Modules'),

    'routes' => [

        // Settings applied to every module Routes/web.php file.
        'web' => [
            'middleware' => ['web'],
        ],

        // Settings applied to every module Routes/api.php file.
        'api' => [
            [
                'version' => 'v1',
                'filename' => 'api',
                'middleware' => ['api'],
            ],
        ],
    ],
];

For example, a route named products.index in a module's API route file is available as api.v1.products.index by default, and its URI starts with /api/v1.

Testing

composer test

License

The MIT License (MIT). Please see License File for more information.