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

Shop Bundle Laravel Package

bleuebuzz/shop-bundle

View on GitHub
Deep Wiki
Context7

Getting Started

Minimal Setup

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

    composer require bleuebuzz/shop-bundle
    

    Enable it in config/bundles.php:

    return [
        // ...
        Bleuebuzz\ShopBundle\BleuebuzzShopBundle::class => ['all' => true],
    ];
    
  2. Database Configuration Run migrations (check src/Resources/migrations for schema):

    php bin/console doctrine:migrations:migrate
    

    Verify config/packages/bleuebuzz_shop.yaml for connection settings.

  3. First Use Case: Product CRUD Use the provided controllers (ProductController) or create a custom one:

    use Bleuebuzz\ShopBundle\Entity\Product;
    use Bleuebuzz\ShopBundle\Form\ProductType;
    
    // In your controller:
    $product = new Product();
    $form = $this->createForm(ProductType::class, $product);
    

Implementation Patterns

Core Workflows

  1. Product Management

    • Listing: Use ProductRepository with DQL:
      $products = $this->getDoctrine()
          ->getRepository(Product::class)
          ->findBy(['active' => true]);
      
    • Search: Leverage BleuebuzzShopBundle:Product:search route with query params (?q=term).
  2. Cart Integration

    • Attach to Symfony’s session via Bleuebuzz\ShopBundle\Service\CartManager:
      $cart = $this->get('bleuebuzz_shop.cart_manager');
      $cart->add($product, 2); // Add 2 units
      
  3. Checkout

    • Use BleuebuzzShopBundle:Order:checkout with a form handler:
      $order = $cart->checkout($user, $shippingAddress);
      $this->get('bleuebuzz_shop.order_processor')->process($order);
      

Integration Tips

  • Twig Extensions: Access cart totals in templates:
    {{ app.bleuebuzz_shop.cart.total|price }}
    
  • Events: Subscribe to bleuebuzz.shop.order.created for post-purchase logic:
    # config/services.yaml
    services:
        App\EventListener\OrderListener:
            tags:
                - { name: kernel.event_listener, event: bleuebuzz.shop.order.created, method: onOrderCreated }
    

Gotchas and Tips

Pitfalls

  1. Session Cart Dependency

    • Cart data is session-bound. For multi-tab support, use Bleuebuzz\ShopBundle\Service\PersistentCart with Redis:
      # config/packages/bleuebuzz_shop.yaml
      cart:
          persistent: true
          redis_dsn: 'redis://localhost'
      
  2. Translation Quirks

    • Product attributes (e.g., name, description) must be translatable. Use gedmo/translatable:
      composer require gedmo/doctrine-extensions
      
      Enable in config/packages/doctrine.yaml:
      gedmo_translatable:
          default_lifecycle: true
      
  3. Order Status Transitions

    • Custom transitions require overriding Bleuebuzz\ShopBundle\Model\OrderStateMachine:
      $stateMachine->addTransition('cancel', 'pending', 'cancelled');
      

Debugging

  • Cart Issues: Clear session data:
    php bin/console cache:clear
    
  • Form Validation: Check ProductType constraints in src/Form/ProductType.php for hidden rules.

Extension Points

  1. Custom Fields Extend Product entity with traits:

    use Bleuebuzz\ShopBundle\Entity\Traits\CustomProductFields;
    class ExtendedProduct extends Product {
        use CustomProductFields;
    }
    
  2. Payment Gateways Implement Bleuebuzz\ShopBundle\Payment\GatewayInterface:

    class StripeGateway implements GatewayInterface {
        public function pay(Order $order, array $options) { ... }
    }
    

    Register in services.yaml:

    services:
        App\Payment\StripeGateway:
            tags: [bleuebuzz_shop.payment_gateway]
    
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