• This repository has been archived on 10/Jan/2022
  • Stars
    star
    102
  • Rank 334,568 (Top 7 %)
  • Language
    PHP
  • License
    Other
  • Created about 9 years ago
  • Updated over 5 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Admin pack (actions, widgets, etc) for Yii2

Admin pack for Yii 2


This extension provides controllers, actions, widgets and other tools for administration panel creation in Yii2 project.

For license information check the LICENSE-file.

Latest Stable Version Total Downloads Build Status

Installation

The preferred way to install this extension is through composer.

Either run

php composer.phar require --prefer-dist yii2tech/admin

or add

"yii2tech/admin": "*"

to the require section of your composer.json.

Usage

This extension provides controllers, actions, widgets and other tools for administration panel creation in Yii2 project. These tools are meant to be used together for the rapid web application administration panel composition.

This package supports usage of following extensions:

Note: none of these extensions is required by default, you'll need to install them yourself, if needed.

Actions

This extension provides several independent action classes, which provides particular operation support:

  • [[\yii2tech\admin\actions\Index]] - displays the models listing with search support.
  • [[\yii2tech\admin\actions\Create]] - supports creation of the new model using web form.
  • [[\yii2tech\admin\actions\Update]] - supports updating of the existing model using web form.
  • [[\yii2tech\admin\actions\Delete]] - performs the deleting of the existing record.
  • [[\yii2tech\admin\actions\View]] - displays an existing model.
  • [[\yii2tech\admin\actions\SoftDelete]] - performs the "soft" deleting of the existing record.
  • [[\yii2tech\admin\actions\SafeDelete]] - performs the "safe" deleting of the existing record.
  • [[\yii2tech\admin\actions\Restore]] - performs the restoration of the "soft" deleted record.
  • [[\yii2tech\admin\actions\Callback]] - allows invocation of specified method of the model.
  • [[\yii2tech\admin\actions\Position]] - allows change custom sort position of the particular model.
  • [[\yii2tech\admin\actions\VariationCreate]] - supports creation of the new model with variations using web form.
  • [[\yii2tech\admin\actions\VariationUpdate]] - supports updating of the new model with variations using web form.
  • [[\yii2tech\admin\actions\RoleCreate]] - supports creation of the new model with role using web form.
  • [[\yii2tech\admin\actions\RoleUpdate]] - supports updating of the new model with role using web form.

Please refer to the particular action class for more details.

For example CRUD controller based on provided actions may look like following:

namespace app\controllers;

use yii\web\Controller;

class ItemController extends Controller
{
    public function actions()
    {
        return [
            'index' => [
                'class' => \yii2tech\admin\actions\Index::class,
                'newSearchModel' => function () {
                    return new ItemSearch();
                },
            ],
            'view' => [
                'class' => \yii2tech\admin\actions\View::class,
            ],
            'create' => [
                'class' => \yii2tech\admin\actions\Create::class,
            ],
            'update' => [
                'class' => \yii2tech\admin\actions\Update::class,
            ],
            'delete' => [
                'class' => \yii2tech\admin\actions\Delete::class,
            ],
        ];
    }

    public function findModel($id)
    {
        if (($model = Item::findOne($id)) !== null) {
            return $model;
        }
        throw new NotFoundHttpException('The requested page does not exist.');
    }

    public function newModel()
    {
        return new Item();
    }
}

Controllers

This extension provides several predefined controllers, which can be used as a base controller classes while creating particular controllers:

  • [[\yii2tech\admin\CrudController]] - implements a common set of actions for supporting CRUD for ActiveRecord.

Please refer to the particular controller class for more details.

Widgets

This extension provides several widgets, which simplifies view composition for the typical use cases:

  • [[\yii2tech\admin\widgets\Alert]] - renders a message from session flash.
  • [[\yii2tech\admin\widgets\ActionAlert]] - renders an action proposition based on particular condition, usually a session flag.
  • [[\yii2tech\admin\widgets\ButtonContextMenu]] - simplifies rendering of the context links such as 'update', 'view', 'delete' etc.
  • [[\yii2tech\admin\widgets\Nav]] - enhanced version of [[\yii\bootstrap\Nav]], which simplifies icon rendering.

Also several enhancements for the [[\yii\grid\GridView]] are available:

  • [[\yii2tech\admin\grid\ActionColumn]] - simplifies composition of the action buttons
  • [[\yii2tech\admin\grid\DeleteStatusColumn]] - serves for the 'soft-deleted' status displaying
  • [[\yii2tech\admin\grid\PositionColumn]] - provides simple interface for the model custom sort position switching
  • [[\yii2tech\admin\grid\VariationColumn]] - allows displaying of the variation column values

Using Gii

This extension provides a code generators, which can be integrated with yii 'gii' module. In order to enable them, you should adjust your application configuration in following way:

return [
    //....
    'modules' => [
        // ...
        'gii' => [
            'class' => yii\gii\Module::class,
            'generators' => [
                'adminMainFrame' => [
                    'class' => yii2tech\admin\gii\mainframe\Generator::class
                ],
                'adminCrud' => [
                    'class' => yii2tech\admin\gii\crud\Generator::class
                ]
            ],
        ],
    ]
];

"MainFrame" generator creates a basic admin panel code, which includes layout files, main controller file and basic view files. The created structure is necessary for the correct rendering of the code created by "Admin CRUD" generator.

"Admin CRUD" generator is similar to regular "CRUD" generator, but it generates code, which uses tools from this extension, so the result code is much more clean.

Internationalization

All text and messages introduced in this extension are translatable under category 'yii2tech-admin'. You may use translations provided within this extension, using following application configuration:

return [
    'components' => [
        'i18n' => [
            'translations' => [
                'yii2tech-admin' => [
                    'class' => yii\i18n\PhpMessageSource::class,
                    'basePath' => '@yii2tech/admin/messages',
                ],
                // ...
            ],
        ],
        // ...
    ],
    // ...
];

More Repositories

1

ar-softdelete

Soft delete behavior for ActiveRecord
PHP
202
star
2

crontab

Yii2 extension for crontab support
PHP
184
star
3

balance

Balance accounting (bookkeeping) system based on debit and credit principle
PHP
174
star
4

file-storage

This package has been abandoned. See: https://www.patreon.com/posts/59332556
PHP
119
star
5

ar-position

ActiveRecord behavior, which provides ability for custom records order setup
PHP
113
star
6

selfupdate

Basic script for project self update from VCS
PHP
92
star
7

csv-grid

Yii2 extension for CSV export
PHP
89
star
8

ar-linkmany

ActiveRecord behavior for saving many-to-many relations
PHP
87
star
9

illuminate

Yii2 to Laravel Migration Package
PHP
87
star
10

embedded

Support embedded models usage for complex ActiveRecord like MongoDB or ElasticSearch
PHP
81
star
11

spreadsheet

Yii2 extension for export to Excel
PHP
81
star
12

html2pdf

Yii2 component for HTML to PDF conversion
PHP
75
star
13

filedb

ActiveRecord for static data definitions based on files
PHP
73
star
14

config

Yii2 application runtime configuration support
PHP
62
star
15

sitemap

Site map creation support
PHP
59
star
16

project-template

Yii2 Project Template
PHP
54
star
17

content

Content management system for Yii2
PHP
53
star
18

ar-variation

Variation behavior for ActiveRecord
PHP
49
star
19

ar-dynattribute

Provide ActiveRecord dynamic attributes stored into the single field in serialized state
PHP
44
star
20

ar-file

This package has been abandoned. See: https://www.patreon.com/posts/59332556
PHP
36
star
21

ar-role

ActiveRecord behavior, which provides relation roles (table inheritance)
PHP
36
star
22

authlog

Identity auth tracking
PHP
33
star
23

ar-search

Provides unified search model for Yii ActiveRecord
PHP
31
star
24

ar-eagerjoin

ActiveRecord behavior, which provides relation eager loading by join without extra query
PHP
21
star
25

behavior-trait

Allows handling events via inline declared methods, which can be added by traits
PHP
20
star
26

install

basic script for project installation
PHP
18
star
27

activemail

Provides ActiveMessage mailing approach for Yii2
PHP
17
star
28

https

Secure connection (https) handling
PHP
11
star
29

model-change

Yii2 model data and state change tracking
PHP
11
star