Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Admin Project Laravel Package

ardteam/admin-project

View on GitHub
Deep Wiki
Context7

Getting Started

Minimal Setup

  1. Installation

    composer require ardteam/admin-project
    

    Add the bundle to AppKernel.php (Symfony 2.x) or config/bundles.php (Symfony 3.x+):

    new Ardteam\AdminProjectBundle\ArdteamAdminProjectBundle(),
    
  2. First Use Case: CRUD Admin Panel

    • Extend SonataAdminBundle (already included) to create a custom admin class:
      use Sonata\AdminBundle\Admin\AbstractAdmin;
      use Sonata\AdminBundle\Datagrid\DatagridMapper;
      use Sonata\AdminBundle\Datagrid\ListMapper;
      use Sonata\AdminBundle\Form\FormMapper;
      
      class PostAdmin extends AbstractAdmin
      {
          protected function configureFormFields(FormMapper $formMapper)
          {
              $formMapper
                  ->add('title')
                  ->add('content');
          }
      
          protected function configureDatagridFilters(DatagridMapper $datagridMapper)
          {
              $datagridMapper
                  ->add('title');
          }
      
          protected function configureListFields(ListMapper $listMapper)
          {
              $listMapper
                  ->add('title')
                  ->add('createdAt');
          }
      }
      
    • Register the admin in services.yml:
      services:
          app.admin.post:
              class: AppBundle\Admin\PostAdmin
              arguments:
                  - ~
                  - AppBundle\Entity\Post
                  - AppBundle:PostAdmin
              tags:
                  - { name: sonata.admin, manager_type: orm, group: Content, label: Post }
      
  3. AdminLTE Integration The bundle includes almasaeed2010/adminlte for UI. Ensure app/config/config.yml has:

    assetic:
        bundles: [FOSJsRoutingBundle, SonataAdminBundle, ArdteamAdminProjectBundle]
    twig:
        form_themes:
            - 'ArdteamAdminProjectBundle:Form:fields.html.twig'
    

Implementation Patterns

Workflow: Rapid Admin Panel Development

  1. Leverage SonataAdminBundle

    • Use pre-built CRUD interfaces for Doctrine entities.
    • Customize via configureFormFields(), configureListFields(), etc.
    • Example: Add a nested admin for Post comments:
      $formMapper->add('comments', 'sonata_type_collection', [
          'by_reference' => false,
      ]);
      
  2. AdminLTE Theming

    • Override templates in app/Resources/ArdteamAdminProjectBundle/views/ (e.g., layout.html.twig).
    • Extend CSS/JS via app/Resources/public/admin/ and include in config.yml:
      assetic:
          assets:
              admin_styles:
                  inputs:
                      - '%kernel.root_dir%/../vendor/almasaeed2010/adminlte/dist/css/adminlte.min.css'
                      - '%kernel.root_dir%/../vendor/almasaeed2010/adminlte/dist/css/skin-blue.min.css'
                      - '%kernel.root_dir%/../src/AppBundle/Resources/public/admin/custom.css'
                  filters: [cssrewrite]
                  output: 'css/admin.css'
      
  3. Security Integration

    • Use Symfony’s security component to restrict access:
      protected function isAccessGranted()
      {
          return $this->getAuthorizationChecker()->isGranted('ROLE_ADMIN');
      }
      
  4. Event Listeners

    • Hook into Sonata events (e.g., sonata.admin.post_persist) for custom logic:
      $eventDispatcher->addListener('sonata.admin.post_persist', function ($event) {
          $post = $event->getSubject();
          $post->setSlug(Str::slug($post->getTitle()));
      });
      

Gotchas and Tips

Pitfalls

  1. SonataAdminBundle Version Mismatch

    • The bundle pins sonata-project/admin-bundle: ~2.3. Ensure all dependencies align:
      composer require sonata-project/admin-bundle:^2.3 sonata-project/doctrine-orm-admin-bundle:^2.3
      
    • Fix: Use composer why-not sonata-project/admin-bundle:^3.0 to debug conflicts.
  2. AdminLTE Asset Loading

    • If AdminLTE styles/js fail to load, verify:
      • assetic:dump is run (php bin/console assetic:dump).
      • Bundles are listed in assetic.bundles (Symfony 2.x) or config/packages/assetic.yaml (Symfony 3.x+).
    • Tip: Use {% block javascripts %} in layout.html.twig to manually include:
      {{ parent() }}
      <script src="{{ asset('bundles/ardteamadminproject/js/adminlte.js') }}"></script>
      
  3. Doctrine ORM Quirks

    • The bundle requires doctrine/orm: ~2.2. Newer versions may break compatibility.
    • Workaround: Use a custom EntityManager or patch the bundle.
  4. Translation Issues

    • AdminLTE and Sonata use English by default. Override translations in translations/messages.en.yml:
      sonata_admin:
          list:
              actions:
                  list: List
                  edit: Edit
                  delete: Delete
      

Debugging Tips

  1. Enable Sonata Debug Tool Add to config.yml:

    sonata_admin:
        templates:
            layout: 'SonataAdminBundle::standard_layout.html.twig'
        debug: true  # Enable for dev
    
  2. Log Sonata Events Configure Monolog in config.yml:

    monolog:
        handlers:
            sonata:
                type: stream
                path: "%kernel.logs_dir%/sonata.log"
                level: debug
    
  3. Check Route Conflicts Run php bin/console debug:router to ensure admin routes (e.g., /admin/post) don’t clash with custom routes.

Extension Points

  1. Custom Admin Classes

    • Extend Ardteam\AdminProjectBundle\Admin\BaseAdmin (if available) for shared logic:
      class BaseAppAdmin extends Ardteam\AdminProjectBundle\Admin\BaseAdmin
      {
          protected function configureSideMenu()
          {
              $this->menu->addChild('Dashboard', 'fa-home');
          }
      }
      
  2. Dynamic Permissions Use Symfony’s voter system with Sonata:

    $this->addPermission('EDIT', 'Edit Post', 'edit');
    $this->addPermission('DELETE', 'Delete Post', 'delete');
    
  3. API Integration Combine with FOSRestBundle to expose admin actions as APIs:

    sonata_admin:
        options:
            rest:
                enabled: true
    
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
devexploris/shizuku-feature-flags
ecourty/token-bundle
ducrot/twigcn-bundle
bytes-commerce/easy-blog
astroway/sdk-symfony
aljerom/symfony-boilerplate
alengo/sulu-mcp-server-bundle
ai-gateway/ai-gateway-bundle
softbery/laravel-wweditor
hmdev1/lern
comsave/common
alecsammon/php-raml-parser
chrome-php/wrench
lendable/composer-license-checker
typhoon/reflection
mesilov/moneyphp-percentage
mike42/gfx-php
bookdown/themes
aura/view
aura/html