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

Blog Bundle Laravel Package

aimin/blog-bundle

View on GitHub
Deep Wiki
Context7

Getting Started

Minimal Setup

  1. Installation

    composer require aimin/blog-bundle
    

    Add to config/bundles.php:

    return [
        // ...
        Amin\BlogBundle\AminBlogBundle::class => ['all' => true],
    ];
    
  2. Publish Assets

    php bin/console assets:install
    
  3. Database Migrations Run migrations to create tables:

    php bin/console doctrine:migrations:diff
    php bin/console doctrine:migrations:migrate
    
  4. First Use Case Create a blog post via CLI:

    php bin/console amin:blog:create --title="First Post" --content="Hello World"
    

Implementation Patterns

Core Workflows

  • Post Management Use the amin:blog:create, amin:blog:list, and amin:blog:delete commands for CRUD operations. Example:

    php bin/console amin:blog:list --limit=5
    
  • Frontend Integration Render posts in templates via Twig:

    {% for post in amin_blog_posts() %}
        <h2>{{ post.title }}</h2>
        <p>{{ post.content|truncate(200) }}</p>
    {% endfor %}
    
  • API Endpoints Leverage Symfony’s routing to expose posts as JSON:

    # config/routes.yaml
    amin_blog_posts:
        path: /api/posts
        controller: Amin\BlogBundle\Controller\PostController::index
    

Extending Functionality

  • Custom Fields Extend the Post entity by overriding the bundle’s configuration:

    # config/packages/amin_blog.yaml
    amin_blog:
        post:
            fields:
                - { name: 'custom_field', type: 'string' }
    
  • Event Listeners Subscribe to post events (e.g., PostCreatedEvent) in services.yaml:

    services:
        App\EventListener\BlogListener:
            tags:
                - { name: kernel.event_listener, event: amin.blog.post.created, method: onPostCreated }
    

Gotchas and Tips

Common Pitfalls

  • Symfony Version Mismatch The bundle requires Symfony 4.4.x. Ensure your project matches this version or fork the bundle for compatibility.

  • Missing Assets If CSS/JS fails to load, run:

    php bin/console assets:install --symlink
    
  • Doctrine Configuration Verify doctrine.yaml includes the bundle’s entity mappings:

    orm:
        mappings:
            AminBlogBundle: ~
    

Debugging Tips

  • Command Errors Use --verbose for commands:

    php bin/console amin:blog:create --verbose
    
  • Entity Overrides If extending the Post entity, clear the cache:

    php bin/console cache:clear
    

Extension Points

  • Custom Controllers Override the default PostController by defining a new route with higher priority.

  • Validation Rules Add custom validation to the Post entity:

    use Symfony\Component\Validator\Constraints as Assert;
    
    class Post {
        /**
         * @Assert\Length(min=10)
         */
        private $content;
    }
    
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.
milito/query-filter
apiboxsym/user-bundle
apiboxsym/health-check-bundle
jayeshmepani/jpl-moshier-ephemeris-php
elnasnato/laraliveui
labrodev/rest-sdk
sampaui/sampaui
babelqueue/php-sdk
facebook/capi-param-builder-php
babelqueue/symfony
hamzi/corewatch
minionfactory/raw-hydrator
hexters/coinpayment
rjcodes/rjcms
act-training/laravel-permissions-manager
alimarchal/laravel-chart-of-accounts
babenkoivan/elastic-scout-driver
mkwebdesign/filament-watchdog-v5
renatomarinho/laravel-page-speed
zedmagdy/filament-business-hours