项目作者: appaydin

项目描述 :
Powerful Admin Dashboard for Symfony 5
高级语言: PHP
项目地址: git://github.com/appaydin/pd-admin.git
创建时间: 2018-05-23T16:25:38Z
项目社区:https://github.com/appaydin/pd-admin

开源协议:MIT License

下载


page-login

page-admin

pdAdmin

Supported PHP8 and Composer 2

Symfony Powerful Dashboard & Admin. Developed with Symfony 5, Vue 3, Bootstrap 5 framework.

No changes were made to the symfony structure, the current directory structure is used. A custom namespace for Admin has been created. This field is used for all administrator operations.

The interface is designed to be responsive using Twitter Bootstrap. The least possible dependency was tried to be used.

Properties

  • Messenger was used for queuing.
  • PM2 has been set for background processes.
  • Cron processes are managed by PM2.
  • A special Data Table has been written to the panel (Vue3)
  • Supports CSV, Excel export.
  • Special package written for HTTP vs Mail logging.
  • JWT is used for API login.
  • Responsive design
  • Vue documentation is not yet available, see source file.

Installation

  1. Download pdAdmin
    1. composer create-project appaydin/pd-admin pdadmin
  2. Create and configure the .env file.

  3. Create database schemas

    1. bin/console doctrine:schema:create --force
  4. Run built-in web server
    1. symfony server:start --no-tls -d
  5. Install & Build assets
    1. yarn install
    2. yarn run build
  6. Run Backround Process

    1. pm2 start
    2. # Manuel
    3. # bin/console messenger:consume -vv
    4. # bin/console schedule:run

Documentation

User Management

There is pd-user for user management. All settings are in config/packages/pd_user.yaml file.

  • Create User:
    1. bin/console user:create
  • Change User Password:
    1. bin/console user:changepassword
  • Change User Roles:
    1. bin/console user:role

Multilingual System

User logon for multi language is used. Each user can choose his / her own language.
When you log in, you are automatically redirected.

New languages can be added from the kernel settings. You need to translate manually for the new language.

Delegation

SensioFrameworkExtraBundle is used with Symfony security component. There are three default user roles.

  • ROLE_USER
  • ROLE_SUPER_ADMIN

ROLESUPERADMIN has full authority. ROLE_USER authorities can be restricted and panel access can be turned off in the __security.yaml file.

System Settings

System settings are stored in the database. All settings can be used as parameters after container assembly. Since all settings are compiled with the container
it does not create any additional load on the system. Settings can be configured using Symfony Forms and added to the Settings menu from the outside via the “Menu Event” system.
Clear the cache after changes to system settings, otherwise the new settings will not be enabled.

For general settings, you can add it to src/Admin/Forms/System/GeneralForm

Add New Menu to Settings:

  1. <?php
  2. //src/Admin/Menu/SettingsMenu.php
  3. namespace App\Admin\Menu;
  4. use Pd\MenuBundle\Builder\ItemInterface;
  5. use Pd\MenuBundle\Builder\Menu;
  6. class SettingsMenu extends Menu
  7. {
  8. public function createMenu(array $options = []): ItemInterface
  9. {
  10. // Create Root Item
  11. $menu = $this->createRoot('settings_menu')->setChildAttr([
  12. 'class' => 'nav nav-pills',
  13. 'data-parent' => 'admin_config_general',
  14. ]);
  15. // Create Menu Items
  16. $menu->addChild('nav_config_general')
  17. ->setLabel('nav_config_general')
  18. ->setRoute('admin_config_general')
  19. ->setLinkAttr(['class' => 'nav-item'])
  20. ->setRoles(['ROLE_CONFIG_GENERAL'])
  21. // Email
  22. ->addChildParent('nav_config_email')
  23. ->setLabel('nav_config_email')
  24. ->setRoute('admin_settings_email')
  25. ->setLinkAttr(['class' => 'nav-item'])
  26. ->setRoles(['ROLE_SETTINGS_EMAIL']);
  27. return $menu;
  28. }
  29. }

Create New Widget

Widget system was created with Symfony “EventDispatcher Component”.
It has an adjustable structure for each user and it can be specially designed with “Twig Template” engine.
For more information visit pd-widget

Create New Admin Widget:

  1. <?php
  2. //src/Admin/Widgets/AccountWidget.php
  3. namespace App\Admin\Widgets;
  4. use Pd\WidgetBundle\Builder\Item;
  5. use Pd\WidgetBundle\Event\WidgetEvent;
  6. use Doctrine\ORM\EntityManagerInterface;
  7. use Symfony\Component\HttpFoundation\Request;
  8. class AccountWidget
  9. {
  10. private $entityManager;
  11. public function __construct(EntityManagerInterface $entityManager)
  12. {
  13. $this->entityManager = $entityManager;
  14. }
  15. /**
  16. * Build Widgets.
  17. *
  18. * @param WidgetEvent $event
  19. */
  20. public function builder(WidgetEvent $event)
  21. {
  22. // Get Widget Container
  23. $widgets = $event->getWidgetContainer();
  24. // Add Widgets
  25. $widgets
  26. ->addWidget((new Item('user_statistics', 3600))
  27. ->setGroup('admin') // Widget Adds to "Admin" Group
  28. ->setName('widget_user_statistics.name')
  29. ->setDescription('widget_user_statistics.description')
  30. ->setTemplate('@Admin/Widget/userStatistics.html.twig')
  31. ->setRole(['ROLE_WIDGET_USERSTATISTICS'])
  32. ->setConfigProcess(function (Request $request) {
  33. /**
  34. * Controller for Widget Settings
  35. * The return value is stored in the user specific database
  36. */
  37. if ($type = $request->get('type')) {
  38. switch ($type) {
  39. case '1week':
  40. return ['type' => '1week'];
  41. case '1month':
  42. return ['type' => '1month'];
  43. case '3month':
  44. return ['type' => '3month'];
  45. }
  46. }
  47. return false;
  48. })
  49. ->setData(function ($config) {
  50. /**
  51. * The return value can be used in the twig template.
  52. * The function will not execute unless you call it in the template.
  53. * You can use the database operations here.
  54. */
  55. // Set Default Config
  56. if (!isset($config['type'])) {
  57. $config['type'] = '1week';
  58. }
  59. // Create Statistics Data
  60. if ($config['type'] === '1month') {
  61. $data = ['chartDay' => '7'];
  62. // Create Data
  63. } else if ($config['type'] === '1month') {
  64. $data = ['chartDay' => '30'];
  65. } else {
  66. $data = ['chartDay' => '90'];
  67. }
  68. return $data;
  69. })
  70. );
  71. }
  72. }

Create New Menu

The menu system was created with Symfony “EventDispatcher Component”.
For each menu created, Event is generated by default, can be turned off by menu configuration.
For more information visit the pd-menu

Create Menu:

  1. <?php
  2. // src/Admin/Menu/MainNav.php
  3. namespace App\Admin\Menu;
  4. use Pd\MenuBundle\Builder\ItemInterface;
  5. use Pd\MenuBundle\Builder\Menu;
  6. class MainNav extends Menu
  7. {
  8. public function createMenu(array $options = []): ItemInterface
  9. {
  10. // Create ROOT Menu
  11. $menu = $this->createRoot('main_menu', true); // Event enabled
  12. // Create Dashboard
  13. $menu->addChild('nav_dashboard', 1)
  14. ->setLabel('nav_dashboard')
  15. ->setRoute('admin_dashboard')
  16. ->setRoles(['ROLE_DASHBOARD'])
  17. ->setExtra('label_icon', 'dashboard');
  18. /*
  19. * Create Account Section
  20. */
  21. $menu
  22. ->addChild('nav_account', 5)
  23. ->setLabel('nav_account')
  24. ->setRoute('admin_account_list')
  25. ->setRoles(['ROLE_ACCOUNT_LIST'])
  26. ->setExtra('label_icon', 'people')
  27. // Account List
  28. ->addChild('nav_account', 1)
  29. ->setLabel('nav_account')
  30. ->setRoute('admin_account_list')
  31. ->setRoles(['ROLE_ACCOUNT_LIST'])
  32. // Group List
  33. ->addChildParent('nav_group', 2)
  34. ->setLabel('nav_group')
  35. ->setRoute('admin_account_group_list')
  36. ->setRoles(['ROLE_GROUP_LIST']);
  37. return $menu;
  38. }
  39. }