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

Rest Action Bundle Laravel Package

elao/rest-action-bundle

Symfony bundle adding ready-to-use REST actions (CRUD plus listing) designed to integrate with ElaoAdminBundle. Install via Composer, register the bundle, and configure the serializer (e.g., JMS) to quickly expose admin-friendly REST endpoints.

View on GitHub
Deep Wiki
Context7

Getting Started

Minimal Setup

  1. Installation Add the bundle to your composer.json:

    composer require elao/rest-action-bundle
    

    Enable it in config/bundles.php:

    Elao\RestActionBundle\ElaoRestActionBundle::class => ['all' => true],
    
  2. First Use Case Extend a Symfony form type (e.g., AdminBundle's entity form) with REST actions:

    use Elao\RestActionBundle\Form\Type\RestActionType;
    
    $builder->add('actions', RestActionType::class, [
        'actions' => [
            'edit' => ['route' => 'admin_entity_edit', 'icon' => 'pencil'],
            'delete' => ['route' => 'admin_entity_delete', 'icon' => 'trash'],
        ],
    ]);
    
  3. Template Integration Render actions in Twig:

    {{ form_row(form.actions) }}
    

Implementation Patterns

Workflow Integration

  1. AdminBundle Extension Override AdminBundle's base templates (e.g., ElaoAdminBundle:CRUD:index.html.twig) to include:

    {% block actions %}
        {{ form_row(form.actions) }}
    {% endblock %}
    
  2. Dynamic Action Configuration Fetch actions from a service or database:

    $actions = $this->get('elao_rest_action.action_provider')->getActions($entity);
    $builder->add('actions', RestActionType::class, ['actions' => $actions]);
    
  3. Route-Based Actions Define routes in routing.yml:

    admin_entity_edit:
        path: /admin/entity/{id}/edit
        methods: [GET, POST]
    
  4. Event-Driven Customization Subscribe to elao_rest_action.build_actions event to modify actions dynamically:

    $dispatcher->addListener('elao_rest_action.build_actions', function (BuildActionsEvent $event) {
        $event->addAction('custom', ['route' => 'custom_route']);
    });
    

Gotchas and Tips

Pitfalls

  1. Deprecation Risk Last release in 2015—assess compatibility with modern Symfony (5.4+/Laravel 9+). May require patches or forks.

  2. AdminBundle Dependency Requires elao/admin-bundle (not Laravel-native). Adapt templates/routes to Laravel conventions if needed.

  3. Twig Template Overrides Ensure template paths align with AdminBundle's structure. Use {% extends %} correctly to avoid missing blocks.

Debugging

  • Action Not Rendering? Verify:

    • Form type is added to the builder.
    • Twig template includes {{ form_row(form.actions) }}.
    • Routes are correctly defined and accessible.
  • CSRF Issues If using POST actions, ensure _csrf_token is included in forms (Symfony’s default behavior).

Extension Points

  1. Custom Action Types Extend Elao\RestActionBundle\Form\Type\RestActionType to support new action formats (e.g., buttons with modals).

  2. Permission Handling Integrate with Symfony’s security system:

    if (!$this->isGranted('ROLE_ADMIN')) {
        unset($actions['delete']);
    }
    
  3. Laravel Adaptation

    • Replace AdminBundle templates with Laravel Blade.
    • Use Laravel’s route model binding instead of Symfony’s admin_entity_edit routes.
    • Mock elao_rest_action.action_provider with a Laravel service provider.
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.
skyraptor/chatter
edlugz/sasapay
abbasudo/artisan-route
mirvan/ippanel
ignibyte/aic-framework
glavweb/data-schema-bundle
glavweb/datagrid-bundle
tacticmedia/scim-server
uni-method/frame
neika-ai/sdk
adachsoft/php-code-style
pharaonic/laravel-notification-dependencies
beautinow/translug
dev-brainiac/bot-cloaked
octoberrain/html
octoberrain/extension
octoberrain/exception
octoberrain/contracts
adachsoft/api-version-bundle
cgv/localized-resource