Shared Yii2 backend scaffold: models, controllers, migrations, RBAC, mail templates, and CLI.

Maintainers

Package info

github.com/yii2-extensions/app-base

Type:yii2-scaffold

pkg:composer/yii2-extensions/app-base

Statistics

Installs: 33

Dependents: 0

Suggesters: 0

Stars: 1

Open Issues: 0

dev-main / 0.1.x-dev 2026-04-24 01:12 UTC

This package is auto-updated.

Last update: 2026-04-24 01:13:42 UTC


README

Yii Framework

App Base


Build Codecov PHPStan

Shared Yii2 backend distributed as a yii2-extensions/scaffold provider
User model, auth, RBAC, migrations, mail, console, web entrypoints.

Features

Feature Overview

What is a scaffold provider?

app-base is not a runtime library; there is no class to extend or service to register.

It is a yii2-extensions/scaffold provider ; a package that declares a set of files to copy into a consumer project.

On composer install, the scaffold plugin reads scaffold.json from this package and copies src/, config/, rbac/, resources/, public/ and yii into the consumer root. Files that are marked as preserve (configs, RBAC, runtime assets) are only written once, so your edits survive subsequent installs.

See docs/scaffold.md for the detailed walkthrough.

Requirements

  • PHP >=8.3
  • yiisoft/yii2 ^22.0@dev
  • yii2-extensions/scaffold ^0.1@dev
  • A frontend overlay provider for views, CSS, and JS ; see docs/frontend-overlays.md.

Quick start

Create a new directory for your app, drop in this composer.json, then run composer install:

{
    "name": "my-company/my-app",
    "type": "project",
    "minimum-stability": "dev",
    "prefer-stable": true,
    "require": {
        "php": ">=8.3",
        "yii2-extensions/app-base": "^22.0@dev",
        "yii2-extensions/app-jquery": "^22.0@dev"
    },
    "require-dev": {
        "yii2-extensions/scaffold": "^0.1@dev"
    },
    "extra": {
        "scaffold": {
            "allowed-packages": [
                "yii2-extensions/app-base",
                "yii2-extensions/app-jquery"
            ]
        },
        "yii\\composer\\Installer::postCreateProject": {
            "setPermission": [
                {
                    "runtime": "0775",
                    "public/assets": "0775",
                    "yii": "0755"
                }
            ]
        },
        "yii\\composer\\Installer::postInstall": {
            "generateCookieValidationKey": [
                "config/web.php"
            ]
        }
    },
    "config": {
        "allow-plugins": {
            "yii2-extensions/scaffold": true,
            "yiisoft/yii2-composer": true
        }
    },
    "scripts": {
        "post-create-project-cmd": [
            "yii\\composer\\Installer::postCreateProject",
            "yii\\composer\\Installer::postInstall"
        ],
        "post-install-cmd": [
            "yii\\composer\\Installer::postInstall"
        ]
    }
}

Then:

composer install                                    # scaffold copies the tree in + autogenerates cookieValidationKey
./yii migrate                                       # creates the user table + admin user
php -S localhost:8080 -t public public/router.php   # start the dev server

Full walkthrough: docs/installation.md.

What ships

After composer install, the consumer project tree looks like this:

your-app/
├── src/
│   ├── controllers/       SiteController, UserController
│   ├── models/            User ActiveRecord + 8 form models + UserSearch
│   ├── migrations/        CreateUserTable, CreateAdminUser
│   └── commands/          HelloController (console entry-point example)
├── config/                [preserve] web.php, console.php, db.php, params.php, test.php, test_db.php
├── rbac/                  [preserve] items.php, rules.php, assignments.php
├── resources/
│   ├── mail/              HTML + text templates (emailVerify, passwordResetToken) + layouts
│   └── views/             layouts/main, site/*, user/* ; rendered by the frontend overlay
├── public/                index.php, index-test.php, router.php (built-in server), assets/, images/
├── runtime/               [preserve] .gitignore (cache, logs, db.sqlite land here)
├── yii                    Console entry point
└── scaffold.json          Provider manifest (copy paths, per-file modes)

[preserve] = scaffold writes the file once and never overwrites it on subsequent composer install runs. All other paths are refreshed from the provider stubs unless you explicitly scaffold eject them.

Not included (by design)

  • CSS, JS, widgets, and asset bundles ; owned by frontend overlays such as yii2-extensions/app-jquery.
  • Server configuration (.htaccess, nginx.conf, Caddyfile, .rr.yaml); lives in dedicated yii2-extensions/server-* providers.

Documentation

For detailed configuration, scaffold internals, and consumer setup.

Package information

PHP Yii 22.0.x Latest Stable Version Total Downloads

Quality code

PHPStan Level Max Super-Linter StyleCI

Our social networks

Follow on X

License

License