Weave 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

Solid Bundle Laravel Package

dgarden/solid-bundle

View on GitHub
Deep Wiki
Context7

Getting Started

Minimal Setup

  1. Installation:

    composer require dgarden/solid-bundle
    

    Ensure SonataAdminBundle is already installed and configured.

  2. Enable the Bundle: Add to config/bundles.php:

    Dgarden\SolidBundle\DgardenSolidBundle::class => ['all' => true],
    
  3. First Use Case: Annotate a Sonata Admin class with @Solid attributes to override default behaviors:

    use Dgarden\SolidBundle\Annotation\Solid;
    
    /**
     * @Solid(
     *     list="custom_list",  // Override list template
     *     edit="custom_edit"   // Override edit template
     * )
     */
    class PostAdmin extends AbstractAdmin
    {
        // ...
    }
    
  4. Key Files:

    • src/Annotation/Solid.php: Attribute definitions.
    • Resources/config/services.yaml: Bundle services (check for overrides).
    • Resources/views/: Default templates (extend/modify these).

Implementation Patterns

Common Workflows

  1. Template Overrides: Use @Solid to replace Sonata’s default templates (e.g., list, edit, show).

    /**
     * @Solid(list="AppBundle:Admin/post_list.html.twig")
     */
    class PostAdmin extends AbstractAdmin {}
    
  2. Dynamic Configuration: Combine with Sonata’s configure*() methods for runtime logic:

    public function configureListFields(ListMapper $listMapper)
    {
        $listMapper->add('title');
        // Override via @Solid if needed
    }
    
  3. Field-Specific Attributes: Override individual fields (e.g., edit, filter, form):

    /**
     * @Solid(
     *     fields={
     *         "title"={"edit"="custom_title_edit"}
     *     }
     * )
     */
    
  4. Integration with Twig: Extend base templates in templates/admin/:

    {# app/Resources/views/Admin/post_list.html.twig #}
    {% extends '@DgardenSolid/CRUD/list.html.twig' %}
    

Best Practices

  • Namespace Conflicts: Prefix custom templates (e.g., AppBundle:Admin/post_*).
  • Caching: Clear cache after attribute changes:
    php bin/console cache:clear
    
  • Testing: Use phpunit to validate attribute parsing (check tests/ for examples).

Gotchas and Tips

Pitfalls

  1. Attribute Parsing:

    • Ensure annotations is enabled in framework.yaml:
      framework:
          annotations: true
      
    • Debug Tip: Use php bin/console debug:container dgarden.solid.attribute_reader to verify service registration.
  2. Template Priority:

    • @Solid overrides take precedence over Sonata’s defaults but not explicit configure*() methods.
    • Fix: Use prependView() or appendView() in configureListFields() for hybrid approaches.
  3. GitFlow Quirks:

    • Hotfix branches may conflict with develop if not rebased. Prefer git merge --no-ff for clarity.
  4. Missing Documentation:

    • Undocumented attributes (e.g., batch_actions). Inspect src/Annotation/Solid.php for all options.

Debugging Tips

  • Attribute Not Applied? Check if the admin class is properly scanned. Add a dump() in a compiler pass:

    // src/DependencyInjection/Compiler/SolidPass.php
    public function process(ContainerBuilder $container) {
        $admins = $container->findTaggedServiceIds('sonata.admin');
        dump(array_keys($admins)); // Verify your admin is tagged
    }
    
  • Template Not Found? Ensure the template path is correct (use absolute paths like AppBundle:Admin/post_list.html.twig).

Extension Points

  1. Custom Attributes: Extend Solid annotation by creating a subclass:

    #[Attribute(Attribute::TARGET_CLASS)]
    class CustomSolid extends Solid {}
    
  2. Compiler Passes: Override the bundle’s compiler pass in config/packages/dgarden_solid.yaml:

    dgarden_solid:
        compiler_passes:
            - App\Custom\SolidPass
    
  3. Event Subscribers: Listen to sonata.admin.event.configure to dynamically modify attributes:

    public static function getSubscribedEvents()
    {
        return [
            'sonata.admin.event.configure' => 'onConfigure',
        ];
    }
    
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.
takashato/laravel-vietqr
aitor24/laralang
kraenzle-ritter/entity-relations
dindigital/din-image
pomirleanu/image-colors
sawmainek/laravel-api-generator
delatbabel/jsonresponses
mouhamedfd/permissions-generator
eduplus/qr
laravel2580/idehelpers
delatbabel/viewpages
anavel/gettext
muhamadrezaar/highcharts
delatbabel/keylists
frankkessler/salesforce-laravel-oauth2-rest
anavel/foundation
wdmtech/enviricons
eii/laravel-captcha
muka/shape-reader
tdt/json