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

Core Bundle Laravel Package

ekyna/core-bundle

View on GitHub
Deep Wiki
Context7

Getting Started

Minimal Steps

  1. Installation Add the package via Composer:

    composer require ekyna/core-bundle
    

    Enable the bundle in config/bundles.php (Symfony 4+):

    Ekyna\CoreBundle\EkynaCoreBundle::class => ['all' => true],
    
  2. First Use Case: Doctrine Entity Listener Resolver Register a listener dynamically in a service:

    # config/services.yaml
    services:
        App\EventListener\MyListener:
            tags:
                - { name: 'ekyna.core.listener', entity: 'App\Entity\MyEntity' }
    
  3. First Use Case: Twig Extensions Use the provided Twig extensions in templates:

    {{ text|intl_translate }}
    {{ text|html_safe }}
    

Implementation Patterns

Doctrine Entity Listener Resolver

  • Dynamic Registration: Tag services with ekyna.core.listener to auto-register listeners for specific entities.
  • Priority Handling: Use the priority option in the tag to control listener execution order.
  • Event Types: Supports prePersist, preUpdate, preRemove, etc. via the event option.

CMF Chain Router

  • Dynamic Routes: Register routes programmatically:
    $this->container->get('ekyna_core.router.chain')->addRoute(
        'my_route',
        new Route('/path', new \Symfony\Component\HttpKernel\TerminableMiddlewareStack())
    );
    
  • Integration: Works with Symfony’s router system; useful for modular routing in large applications.

Twig Extensions

  • Text Utilities: Use intl_translate for locale-aware text processing.
  • HTML Safety: Apply html_safe to escape HTML in templates.
  • Intl Functions: Leverage intl_plural or intl_select for localization.

Workflows

  1. Listener-Driven Logic:
    • Use for auditing, soft deletes, or pre-processing entities.
    • Example: Auto-timestamping entities via TimestampableInterface (if implemented).
  2. Routing Flexibility:
    • Dynamically add/remove routes based on user roles or features.
  3. Template Reusability:
    • Centralize text processing (e.g., translations, formatting) in Twig.

Gotchas and Tips

Pitfalls

  1. Outdated Codebase:
    • Last release in 2015; test thoroughly. Some Symfony/Doctrine features may not align with modern versions.
    • TimestampableInterface: Marked as TODO; may not work out-of-the-box.
  2. Configuration Quirks:
    • No clear docs for CmfChainRouter setup (e.g., how to integrate with Symfony’s router).
    • Twig extensions may conflict with other bundles providing similar functionality.
  3. Bootstrap Issues:
    • "Fix default bootstrap less files" suggests potential CSS/asset loading problems.

Debugging

  • Listener Registration: Check if listeners are fired via Symfony’s debug:event-dispatcher:
    php bin/console debug:event-dispatcher
    
  • Router Conflicts: Clear cache after dynamic route additions:
    php bin/console cache:clear
    
  • Twig Errors: Verify extension namespaces (e.g., ekyna_core_text) match the bundle’s actual implementation.

Extension Points

  1. Custom Listeners: Extend the resolver by implementing Ekyna\CoreBundle\Listener\ListenerResolverInterface.
  2. New Twig Functions: Add extensions via ekyna_core.twig.extension service tag.
  3. Router Middleware: Override Ekyna\CoreBundle\Router\ChainRouter to customize route handling.

Tips

  • Fallbacks: For critical features, implement redundant logic (e.g., manual listeners) if the bundle fails.
  • Testing: Mock the bundle’s services in unit tests to avoid dependency issues.
  • Community: Check GitHub issues for undocumented features (e.g., translations validation).
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.
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
aura/cli
povils/phpmnd
nayjest/manipulator
omnipay/tests
psr-mock/http-message-implementation
psr-mock/http-factory-implementation
psr-mock/http-client-implementation
voku/email-check
voku/urlify
rtheunissen/guzzle-log-middleware