PHPackages                             new-japan-orders/scaffold - 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. new-japan-orders/scaffold

ActiveLibrary

new-japan-orders/scaffold
=========================

0.0.1(8y ago)040MITPHP

Since May 10Pushed 7y ago1 watchersCompare

[ Source](https://github.com/new-japan-orders/scaffold)[ Packagist](https://packagist.org/packages/new-japan-orders/scaffold)[ RSS](/packages/new-japan-orders-scaffold/feed)WikiDiscussions master Synced today

READMEChangelogDependencies (2)Versions (2)Used By (0)

scaffold
========

[](#scaffold)

概要
--

[](#概要)

### 目的

[](#目的)

フロントとバックエンドは分離したい。 けどアプリを2つ作るほどの規模じゃない。 なのでディレクトリで分離する。 中小規模でのCMS開発がターゲット。

### ディレクトリ構成

[](#ディレクトリ構成)

例えば以下のようにコマンドを実行した場合。

```
php artisan scaffold:init front user

```

ディレクトリ構成は以下のようになります。

```
base_path
├ app
│   ├ Models
│   │   └ User.php
│   └ Policies
├ front
│   ├ Http
│   │   └ Controllers
│   │       ├ Controller.php
│   │       ├ HomeController.php
│   │       └ Auth
│   │           ├ LoginController.php
│   │           ├ ForgetController.php
│   │           ├ RegisterController.php
│   │           └ ResetController.php
│   ├ Policies
│   └ Notifications
│       └ ResetPassword.php
├ resources
│   └ views
│       └ front
│           ├ home.blade.php
│           ├ layouts
│           │   └ app.blade.php
│           └ auth
│               ├ login.blade.php
│               ├ register.blade.php
│               └ passwords
│                   ├ reset.blade.php
│                   └ email.blade.php
└ routes
    └ front.php

```

init
----

[](#init)

scaffold:initコマンドを利用すると、 前述のディレクトリ構成を作成した上で、 MultiAuthに必要なControllerやModelを用意できます。 このコマンドは、scaffold:appとscaffold:authを実行するのと同じ意味です。

```
php artisan scaffold:init front user
        ↑

        ↓
php artisan scaffold:app front
php artisan scaffold:auth front user

```

### 使い方

[](#使い方)

frontとadminの2つ作る例。

#### コマンド実行例

[](#コマンド実行例)

```
php artisan scaffold:init front user
php artisan scaffold:init admin admin
php artisan migrate
php artisan db:seed --class UserSeeder
php artisan db:seed --class AdminSeeder

```

#### composer autoloadの設定

[](#composer-autoloadの設定)

composer.json

```
    "autoload": {
        "psr-4": {
            "App\\": "app/",
            "Front\\": "front/",
            "Admin\\": "admin/"
        }
    },

```

編集後にcomposer dump-autoloadする。

#### MultiAuthの設定

[](#multiauthの設定)

config/auth.php

```

return [
    'defaults' => [
        'guard' => 'front',
        'passwords' => 'users',
    ],
    'guards' => [
        'web' => [
            'driver' => 'session',
            'provider' => 'users',
        ],
        'front' => [
            'driver' => 'session',
            'provider' => 'users',
        ],
        'admin' => [
            'driver' => 'session',
            'provider' => 'admins',
        ],
        'api' => [
            'driver' => 'token',
            'provider' => 'users',
        ],
    ],
    'providers' => [
        'users' => [
            'driver' => 'eloquent',
            'model' => App\User::class,
        ],
        'admins' => [
            'driver' => 'eloquent',
            'model' => App\Admin::class,
        ],

        // 'users' => [
        //     'driver' => 'database',
        //     'table' => 'users',
        // ],
    ],
    'passwords' => [
        'front' => [
            'provider' => 'users',
            'table' => 'user_password_resets',
            'expire' => 60,
        ],
        'admin' => [
            'provider' => 'admins',
            'table' => 'admin_password_resets',
            'expire' => 60,
        ],
    ],
];

```

#### 認証済みの際のRedirect先修正

[](#認証済みの際のredirect先修正)

app/Http/Middleware/RedirectIfAuthenticated.php

```

    public function handle($request, Closure $next, $guard = null)
    {
        if (Auth::guard($guard)->check()) {
            return redirect($guard.'/home');
        }

        return $next($request);
    }

```

#### 認証失敗時のリダイレクト先の修正

[](#認証失敗時のリダイレクト先の修正)

app/Exceptions/Handler.php

```

    protected function unauthenticated($request, AuthenticationException $exception)
    {
        if ($request->expectsJson()) {
            return response()->json(['error' => 'Unauthenticated.'], 401);
        }

        if (in_array('admin', $exception->guards())) {
            return redirect()->guest(route('admin.login'));
        }
        return redirect()->guest(route('front.login'));
    }

```

#### routeの設定

[](#routeの設定)

app/Providers/RouteServiceProvider.php

```
    protected function mapWebRoutes()
    {
        Route::middleware('web')
             ->namespace('Front\Http\Controllers')
             ->group(base_path('routes/front.php'));

        Route::middleware('web')
             ->namespace('Admin\Http\Controllers')
             ->group(base_path('routes/admin.php'));
    }

```

mvc
---

[](#mvc)

scaffold:mvcコマンドを利用すると、 前述のディレクトリ構成を作成した上で、 Model, Controller, Viewの3つを作成します。 このコマンドは、

- scaffold:controller
- scaffold:model
- scaffold:view

を実行するのと同じ意味です。

```
php artisan scaffold:mvc front user car
        ↑

        ↓
php artisan scaffold:controller front car
php artisan scaffold:model car
php artisan scaffold:view front user car

```

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity53

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

Unknown

Total

1

Last Release

2924d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/99beefb510199cae54340a7fbfce48e094562f58601c469ddb13ef9354a8177e?d=identicon)[emile-yamaji](/maintainers/emile-yamaji)

---

Top Contributors

[![emile-yamaji](https://avatars.githubusercontent.com/u/11953776?v=4)](https://github.com/emile-yamaji "emile-yamaji (13 commits)")

### Embed Badge

![Health badge](/badges/new-japan-orders-scaffold/health.svg)

```
[![Health](https://phpackages.com/badges/new-japan-orders-scaffold/health.svg)](https://phpackages.com/packages/new-japan-orders-scaffold)
```

###  Alternatives

[fumeapp/modeltyper

Generate TypeScript interfaces from Laravel Models

196277.9k](/packages/fumeapp-modeltyper)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

255.2k](/packages/aedart-athenaeum)

PHPackages © 2026

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