GithubHelp home page GithubHelp logo

naffiq / yii2-bridge Goto Github PK

View Code? Open in Web Editor NEW
4.0 3.0 3.0 596 KB

⚠️ REPO MOVED TO SEPARATE GROUP FOR MAINTAINABILITY

Home Page: https://github.com/yii2-bridge/core

PHP 96.55% CSS 3.20% Shell 0.25%
yii2 admin admin-panel admin-dashboard crud cmf cms generator gii

yii2-bridge's Introduction

Yii2 Bridge Build Status Maintainability

Yet another admin panel

Bridge delivers you simple content management system that utilizes best production-tested components and plugins for Yii2.

Installation

Add it as Composer dependency by running

$ composer require naffiq/yii2-bridge

 Be sure to configure module (instructions below), before running migrations.

Configuration

Add module declaration to your config file for web config:

<?php

return [
    // ... your config
    'modules' => [
        'admin' => [
            'class' => '\naffiq\bridge\BridgeModule',
            // Add your projects modules here to keep right routing.
            'modules' => [
                'customModule' => ['class' => '\app\modules\your\CustomModule']
            ],
            // Add menu item of your content management module to menu
            'menu' => [
                [
                    'title' => 'Content',
                    'url' => ['/admin/content/default/index'],
                    'active' => ['module' => 'content'],
                    'icon' => 'list'
                ]
            ],
            // Alternatively you can define different menu items for different
            // roles. In that case it will override default menu items, such as
            // settings, users and dashboard
            'composeMenu' => function ($user, $roles, $authManager) {
                 /**
                  * @var \yii\web\User $user 
                  * @var \Da\User\Model\Role[] $roles
                  * @var \Da\User\Component\AuthDbManagerComponent $authManager 
                  */
                 if (isset($roles['admin'])) {
                     return require __DIR__ . '/menu-admin.php';
                 }
                 if ($user->can('editor')) {
                     return require __DIR__ . '/menu-editor.php';
                 }
                 if (in_array($user->id, $authManager->getUserIdsByRole('manager'))) {
                     return require __DIR__ . '/menu-manager.php';
                 }
                 // Or any other available method
                 
                 return __DIR__ . '/menu-default.php';
            }
        ]
    ],
    'bootstrap' => [        
        'admin' // add module id to bootstrap for proper aliases and url routes binding
    ]
];

And for console config, in order to run migrations:

<?php
return [
    // ... your config
    'modules' => [
        'admin' => ['class' => '\naffiq\bridge\BridgeModule']
    ],
    'bootstrap' => [        
        'admin' // add module id to bootstrap for proper aliases and url routes binding
    ]
]; 

Setup

After installing and config setup (including database), you should have installation executable in your vendor folder. You can run all the migrations required with single command:

$ ./vendor/bin/bridge-install

Warning! This command is running with --interactive=0 flag, which means it will not ask confirmation for it.

Usage

After running every step above you should have your admin panel running on /admin route. The only thing left is to run command to create users.

Creating first user

Run following command to generate users:

$ php yii user/create EMAIL USERNAME PASSWORD ROLE 

So the correct command to create user with admin role for admin panel would be:

$ php yii user/create [email protected] admin PASSWORD admin

Gii

Gii that is provided with bridge is packed with some improvements to basic gii. When generating model with db fields ending by image or file, it would automatically add corresponding upload behavior. You can turn this behaviors off by clicking on checkbox in generator interface.

And also it has Bridge CRUD generator, which will generate necessary fields inputs and display it nicely to the index table.

Development and testing

Configure your .env (refer to .env.example). Run migrations with:

$ ./bin/bridge-install-dev

Bridge comes with console app for development and testing purposes, located in bin folder. You can simply execute it with

$ php bin/yii.php CONTROLLER/ACTION [params]

Test package with

$ ./vendor/bin/phpunit

yii2-bridge's People

Contributors

kuharenko avatar naffiq avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

yii2-bridge's Issues

Translations

  • i18n migrations
  • translations panel
  • languages list
  • init handler

Update admin Settings usage

Since deprecation of Settings::getOrCreate we have to update its usage in admin layout (title and footer) ASAP.

Gii generators for models and crud

Create generator for CRUD:

  • Override yii2tech admin
  • Generate _form.php file with custom ActiveForm
  • Generate _form.php file with image input, date pickers, swithes, and rich text editors
  • Generate index.php file with custom column widgets

Create generator for models:

  • Generate model file with behaviors and rules for image upload

Gii generate index view syntax error

When model has text column and gii generate Truncated column with syntax error

 // [
            'class' => 'naffiq\bridge\widgets\columns\TruncatedTextColumn',
            'attribute' => 'description',
        ],

square bracket is commented

Custom grid columns

Provide grid columns, such as:

  • Image with the title
  • Image
  • Truncated and stripped text

Group settings

Sort settings by groups.

  • OOP pattern usage (Ex: Settings::group('main_page')->getOrCreate('hero_text'))
  • Icon setup (Font Awesome v4.7)
  • Subgroups (considered unnecessary for now)

Create yii2 starter app

In order to create projects with ease, we have to provide yii2-bridge-app with environments (#18) and modules set up.

Settings translation

@naffiq Предлагаю сделать настройки мультиязычным.
Будет еще одна таблица setting_translations, с полями setting_id, lang и value (колонку value у основной таблицы settings уберем).
1

Menu editor

Create different menus and use them inside admin panel and any project

Cache and lazy loading for settings

Add method for fetching all settings with single query and ability for user to change behavior to lazy load.
Cache result of that query for better performance.

Раздел Wiki

Спроектировать раздел Wiki. Генерировать страницы в вики вместе с CRUD

Ошибка сценария

Ошибка сценария create.
В моем случаи ошибка появляется при создании поста.
Поля:
Id => textInput
Title => textInput
Content => textArea
Is Active => switchInput

2018-01-05 12 28 22

Toggle action

{"name":"PHP Warning","message":"Invalid argument supplied for foreach()","code":2,"type":"yii\\base\\ErrorException","file":"/Users/rocketman/rocketdev/adamdar.local/vendor/naffiq/yii2-bridge/src/behaviors/TranslationBehavior.php","line":66,"stack-trace":["#0 /Users/rocketman/rocketdev/adamdar.local/vendor/naffiq/yii2-bridge/src/behaviors/TranslationBehavior.php(66): yii\\base\\ErrorHandler->handleError(2, 'Invalid argumen...', '/Users/rocketma...', 66, Array)","#1 [internal function]: naffiq\\bridge\\behaviors\\TranslationBehavior->saveTranslations(Object(yii\\db\\AfterSaveEvent))","#2 /Users/rocketman/rocketdev/adamdar.local/vendor/yiisoft/yii2/base/Component.php(627): call_user_func(Array, Object(yii\\db\\AfterSaveEvent))","#3 /Users/rocketman/rocketdev/adamdar.local/vendor/yiisoft/yii2/db/BaseActiveRecord.php(992): yii\\base\\Component->trigger('afterUpdate', Object(yii\\db\\AfterSaveEvent))","#4 /Users/rocketman/rocketdev/adamdar.local/vendor/yiisoft/yii2/db/BaseActiveRecord.php(817): yii\\db\\BaseActiveRecord->afterSave(false, Array)","#5 /Users/rocketman/rocketdev/adamdar.local/vendor/yiisoft/yii2/db/ActiveRecord.php(625): yii\\db\\BaseActiveRecord->updateInternal(Array)","#6 /Users/rocketman/rocketdev/adamdar.local/vendor/yiisoft/yii2/db/BaseActiveRecord.php(673): yii\\db\\ActiveRecord->update(false, Array)","#7 /Users/rocketman/rocketdev/adamdar.local/vendor/2amigos/yii2-grid-view-library/src/actions/ToggleAction.php(103): yii\\db\\BaseActiveRecord->save(false, Array)","#8 [internal function]: dosamigos\\grid\\actions\\ToggleAction->run('1', 'is_active')","#9 /Users/rocketman/rocketdev/adamdar.local/vendor/yiisoft/yii2/base/Action.php(94): call_user_func_array(Array, Array)","#10 /Users/rocketman/rocketdev/adamdar.local/vendor/yiisoft/yii2/base/Controller.php(157): yii\\base\\Action->runWithParams(Array)","#11 /Users/rocketman/rocketdev/adamdar.local/vendor/yiisoft/yii2/base/Module.php(528): yii\\base\\Controller->runAction('toggle', Array)","#12 /Users/rocketman/rocketdev/adamdar.local/vendor/yiisoft/yii2/web/Application.php(103): yii\\base\\Module->runAction('admin/post/post...', Array)","#13 /Users/rocketman/rocketdev/adamdar.local/vendor/yiisoft/yii2/base/Application.php(386): yii\\web\\Application->handleRequest(Object(yii\\web\\Request))","#14 /Users/rocketman/rocketdev/adamdar.local/web/index.php(12): yii\\base\\Application->run()","#15 {main}"]}

Sort settings and settings groups

I have already added necessary columns and behaviors. All is left is user interaction.

  • Sort settings groups (probably drag'n'drop?)
  • Add drag'n'drop lib on settings page
  • Add ajax methods for storing settings groups' order
  • Sort settings

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.