定制 tobento/app-backend 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

tobento/app-backend

最新稳定版本:2.0.2

Composer 安装命令:

composer require tobento/app-backend

包简介

App backend.

README 文档

README

The App Backend is a minimal admin panel using the following main app bundles:

Table of Contents

Getting Started

Add the latest version of the app backend project running this command.

composer require tobento/app-backend

Requirements

  • PHP 8.4 or greater

Documentation

App

Check out the App Skeleton if you are using the skeleton.

You may also check out the App to learn more about the app in general.

Backend Boot

The backend boot is extended :

use Tobento\App\AppFactory;

// Create the app
$app = new AppFactory()->createApp();

// Add directories:
$app->dirs()
    ->dir(realpath(__DIR__.'/../'), 'root')
    ->dir(realpath(__DIR__.'/../app/'), 'app')
    ->dir($app->dir('app').'config', 'config', group: 'config')
    ->dir($app->dir('root').'public', 'public')
    ->dir($app->dir('root').'vendor', 'vendor');

// Adding boots
$app->boot(\Tobento\App\Backend\Boot\Backend::class);

// Run the app
$app->run();

Once booted, you can access the backend by the following URL http://localhost/{project}/public/admin/.

You may change the backend slug admin or even route to another domain in the app/config/apps.php file.

Adding Boots

There are two ways to add backend boots:

Via App Config

In the apps/backend/config/app.php file you can add more boots.

'boots' => [
    // ...
    SomeBoot::class,
],

Via Backend Boot

use Tobento\App\Boot;
use Tobento\App\Backend\Boot\Backend;

class BackendBoots extends Boot
{
    public const BOOT = [
        Backend::class,
    ];
    
    public function boot(Backend $backend): void
    {
        $backend->addBoot(SomeBoot::class);
    }
}

Register your boot:

use Tobento\App\AppFactory;

// Create the app
$app = new AppFactory()->createApp();

// Add directories:
$app->dirs()
    ->dir(realpath(__DIR__.'/../'), 'root')
    ->dir(realpath(__DIR__.'/../app/'), 'app')
    ->dir($app->dir('app').'config', 'config', group: 'config')
    ->dir($app->dir('root').'public', 'public')
    ->dir($app->dir('root').'vendor', 'vendor');

// Adding boots
$app->boot(\Tobento\App\Backend\Boot\Backend::class);
$app->boot(BackendBoots::class);

// Run the app
$app->run();

Adding Dashboard Cards

Use the DashboardCards::class and app on method to add dashboard cards only on demand:

use Tobento\App\Backend\Card\DashboardCards;
use Tobento\App\Card\Factory;

$app->on(
    DashboardCards::class,
    static function(DashboardCards $cards): void {
        // Adding cards:
        $cards->add(name: 'foo', card: new Factory\Table(
            rows: ['foo', 'bar'],
        ));
    }
);

Check out the App Card bundle to learn more.

Adding Searchables

To add searchables, check out the App Search - Adding Searchables section.

Customization

Customize Via App

In your app/src directory you may create a boot customizing specific controllers for instance.

namespace App;

use use Tobento\App\Backend\Controller\RoleCrudController;

class Customization extends Boot
{
    public function boot(): void
    {
        // Custom controller:
        $this->app->set(RoleCrudController::class, \App\CustomRoleCrudController::class);
    }
}

In the apps/backend/config/app.php file add your boot.

'boots' => [
    // ...
    \App\Customization::class,
],

Customize Via App Config

In the apps/backend/config/app.php file you can replace existing boots with your customized boots.

'boots' => [
    // ...
    // Resources:
    //\Tobento\App\Backend\Boot\Roles::class,
    \Tobento\App\Backend\Boot\CustomRoles::class,
    //\Tobento\App\Backend\Boot\Users::class,
    \Tobento\App\Backend\Boot\CustomUsers::class,
    // ...
],

Testing

You may boot the \Tobento\App\Backend\Testing\UserAndRolesBoot::class which will migrate the following users for testing:

Email Smartphone Role Active
admin@example.com - administrator 1
inactive@example.com - administrator 0
editor@example.com 12345678 editor 1
registered@example.com - registered 1
use Tobento\App\AppInterface;

final class SomeBackendAppTest extends \Tobento\App\Testing\TestCase
{
    use \Tobento\App\Testing\Database\MigrateDatabases;
    
    public function createApp(): AppInterface
    {
        $app = $this->createTmpApp(rootDir: __DIR__.'/../..');
        $app->boot(\Tobento\App\Backend\Boot\Backend::class);
        $app->booting();
        
        $app = $app->get(AppsInterface::class)->get('backend')->app();
        $app->boot(\Tobento\App\Seeding\Boot\Seeding::class);
        $app->boot(\Tobento\App\Backend\Testing\UserAndRolesBoot::class);
        return $app;
    }
}

You may check out the following links to learn more about testing.

Credits

统计信息

  • 总下载量: 8
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 4
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-06-04