ikechukwukalu/magicmake

A scaffolding package for an opinionated Laravel coding style.

Maintainers

Package info

github.com/ikechukwukalu/magicmake

pkg:composer/ikechukwukalu/magicmake

Transparency log

Statistics

Installs: 6 531

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 4

v3.0.0 2025-06-02 12:48 UTC

This package is auto-updated.

Last update: 2026-08-03 00:50:24 UTC


README

Latest Version on Packagist Quality Score Code Quality

Github Workflow Status Total Downloads Licence

A Laravel scaffolding package for an opinionated Laravel coding style.

REQUIREMENTS

The published v3.0.0 package declares:

  • PHP 7.3 or newer.
  • Laravel 8 through Laravel 12 component constraints.

These values describe the published Composer constraints. They do not imply that every PHP/Laravel combination has been verified by a version matrix. Review the constraints of the exact package version selected by Composer.

SOURCE AND RELEASE POLICY

Development, tests, feature branches, and pull requests are maintained in the private ikechukwukalu/magic-make development source repository. This public repository is the release destination for reviewed package versions.

Documentation in this repository distinguishes published behavior from approved development work. Generation safety, profiles, modular target paths and namespaces, and explicit response modes remain unreleased until a separately authorized package synchronization and release.

UNRELEASED DEVELOPMENT CONTRACT

The development source has an approved Phase 2 contract for future package synchronization. These options are not available in the published v3.0.0 package.

  • lean: model, migration, factory, and focused model test.
  • standard: the existing opinionated model, migration, contract, repository, service, controller, four requests, API route, factory, and feature-test structure. Standard remains the default.
  • enterprise: Standard plus a feature service provider, repository binding, and modular route/migration registration.

The approved command shape is:

php artisan magic:model Invoice \
    --profile=enterprise \
    --path=app/Domains/Billing \
    --namespace='App\Domains\Billing'

Target paths are project-relative. When only --path is supplied, the namespace is derived from Composer PSR-4 mappings. When only --namespace is supplied, the path is derived only if the mapping is unambiguous. Mismatched, unsafe, or unmapped path/namespace combinations fail during preflight. Selected modular artifacts—including routes, providers, factories, migrations, and tests—remain inside the target boundary.

Modular Standard routes require explicit host-application loading. Enterprise generates a provider that binds the repository and loads boundary-local routes and migrations; the host application must explicitly register that provider. The generator does not silently mutate application provider configuration.

STEPS TO INSTALL

composer require ikechukwukalu/magicmake

SET UP LARAVEL

php artisan install:api

INIT CLASSES

To initialize prepared classes for a new laravel app. This would only run when env('APP_ENV') === local and env(MAGIC_INIT_LOCK) === false.

php artisan magic:init

MODEL BASED CLASSES

To generate all model based prepared classes.

php artisan magic:model UserKyc

To generate individual model based prepared classes.

php artisan magic:contract UserKyc --variable=userKyc --underscore=user_kyc

php artisan magic:repository UserKyc --variable=userKyc --underscore=user_kyc

php artisan magic:service UserKyc --variable=userKyc --underscore=user_kyc

php artisan magic:controller UserKyc --variable=userKyc --underscore=user_kyc

php artisan magic:createRequest UserKyc --variable=userKyc --underscore=user_kyc

php artisan magic:updateRequest UserKyc --variable=userKyc --underscore=user_kyc

php artisan magic:deleteRequest UserKyc --variable=userKyc --underscore=user_kyc

php artisan magic:readRequest UserKyc --variable=userKyc --underscore=user_kyc

php artisan magic:api UserKyc --variable=userKyc --underscore=user_kyc

php artisan magic:test UserKyc --variable=userKyc --underscore=user_kyc

php artisan magic:factory UserKyc --variable=userKyc --underscore=user_kyc

Note

Add this to config/api.php.

    'paginate' => [
        ...
        'user_kyc' => [
            'pageSize' => 10,
        ],
    ],

Add this to app/Providers/RepositoryServiceProvider.php.

use App\Contracts\UserKycRepositoryInterface;
use App\Repositories\UserKycRepository;


public function register(): void
{
    ...
    $this->app->bind(UserKycRepositoryInterface::class, UserKycRepository::class);
}

FINISHING SETUP

If you did run php artisan magic:init.

Add to the composer.json file.

"autoload": {
    "psr-4": {
        "App\\": "app/",
        "Database\\Factories\\": "database/factories/",
        "Database\\Seeders\\": "database/seeders/"
    },
    "files": [
        "app/Http/Helpers.php"
    ]
},

After that run:

composer dump-autoload

Add to bootstrap/providers.php.

/*
    * Package Service Providers...
    */
App\Providers\EventServiceProvider::class,
App\Providers\MacroServiceProvider::class,
App\Providers\RepositoryServiceProvider::class,

Add to bootstrap/app.php

    ->withMiddleware(function (Middleware $middleware) {
        //
        $middleware->alias([
            'check.email.verification' => \App\Http\Middleware\CheckEmailVerification::class,
            'check.user.is.admin' => \App\Http\Middleware\CheckIfUserIsAdmin::class,
            'check.phone.verification' => \App\Http\Middleware\CheckPhoneVerification::class,
        ]);
    })

Add to vite.config.js

import { defineConfig } from 'vite';
import laravel from 'laravel-vite-plugin';

export default defineConfig({
    plugins: [
        laravel({
            input: [
                'resources/sass/app.scss',
                'resources/js/app.js',
                'resources/css/app.css',
            ],
            refresh: true,
        }),
    ],
});

Project setup

php artisan ui bootstrap
npm install
composer install
php artisan migrate --seed

Run development server

npm run build
php artisan serve
php artisan test

NOTE

Publish notification blade

Add the following line above this code line @if ($emailData->action) in the notification.blade.php file:

@if (isset($emailData->highlightText))
@component('mail::panel', ['style' => 'background-color: #f0f8ff; border-radius: 0.5rem; padding: 16px;text-align: center'])
<div style="text-align: center;">
{{ $emailData->highlightText }}
</div>
@endcomponent
@endif

App notification helpers

$userNotificationData = new UserNotificationData($user->id, $title, $text);
$user->notify(new DatabaseNotification($userNotificationData->toObject()));

$emailData = new EmailData(subject: $title, lines: [$text], from: env('MAIL_FROM_ADDRESS'),
    remark: null, action: false, action_text: null,
    action_url: null, attachements: null);
$user->notify(new EmailNotification($emailData->toObject()));

$smsData = new SmsData($user->name, $text);
$user->notify(new SmsNotification($smsData->toObject()));

Advanced search and table filter helpers

Sample usage:

public function getPaginated(int $pageSize): LengthAwarePaginator
{
    /**
     * Search a parent table via the user_id foreign key on the user_deliveries table
     */
    $search = advancedSearch('user', 'user_id', ['unit_number', 'name', 'email', 'first_name', 'last_name', 'middle_name']);

    /**
     * Search a child table via the user_delivery_id foreign key on the user_delivery_items table
     */
    $search2 = advancedSearch('userDeliveryItems', 'user_delivery_id', ['tracking_number', 'name', 'delivery_vendor'], 'user_delivery_items');

    return UserDelivery::with(['user', 'userDeliveryItems'])
                ->search($search)
                ->search($search2)
                ->orWhere(function($query) {
                    $query->search('ref_number');
                })
                ->order()
                ->date()
                ->filter($this->whiteList)
                ->paginate(pageSize($pageSize));
}

LICENSE

The MM package is a software licensed under the Apache 2.0 license.