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

akyos/shop-bundle

View on GitHub
Deep Wiki
Context7

Getting Started

Minimal Setup

  1. Installation

    composer require akyos/shop-bundle
    

    Add to config/bundles.php:

    return [
        // ...
        Akyos\ShopBundle\AkyosShopBundle::class => ['all' => true],
    ];
    
  2. First Use Case: Product Management

    • Run migrations (if provided):
      php bin/console doctrine:migrations:migrate
      
    • Access the admin interface (if available) via /admin/shop (check README for exact route).
    • Create a product via CLI or admin panel:
      php bin/console app:shop:create-product --name="Test Product" --price=19.99
      
  3. Key Configuration Check config/packages/akyos_shop.yaml (auto-generated) for:

    • Default currency, tax rules, or payment gateways.
    • Override defaults in config/packages/akyos_shop.yaml:
      akyos_shop:
          default_currency: 'EUR'
          tax_rate: 20
      

Implementation Patterns

Core Workflows

  1. Product Management

    • CRUD via Admin Panel (if UI is included):
      // Example: Fetch products (if API is exposed)
      $products = $this->getDoctrine()->getRepository(Product::class)->findAll();
      
    • Programmatic Creation:
      use Akyos\ShopBundle\Entity\Product;
      
      $product = new Product();
      $product->setName('Laptop')
              ->setPrice(999.99)
              ->setSku('LP-2023');
      $entityManager->persist($product);
      $entityManager->flush();
      
  2. Cart & Checkout

    • Add to Cart (if cart service is available):
      $cart = $this->get('akyos_shop.cart');
      $cart->add($product, 2); // Add 2 units
      
    • Checkout Flow:
      • Validate cart ($cart->isValid()).
      • Process payment (integrate with akyos_shop.payment service if available).
      • Generate order:
        $order = $this->get('akyos_shop.order_manager')->createOrder($cart);
        
  3. Catalog & Search

    • Filter Products (if repository methods exist):
      $filtered = $this->getDoctrine()
          ->getRepository(Product::class)
          ->findBy(['category' => 'Electronics', 'price' => ['<=' => 500]]);
      
    • CSV Export (leveraging league/csv):
      use League\Csv\Writer;
      
      $csv = Writer::createFromString('');
      $csv->insertOne(['SKU', 'Name', 'Price']);
      foreach ($products as $product) {
          $csv->insertOne([$product->getSku(), $product->getName(), $product->getPrice()]);
      }
      return $csv->getContent();
      
  4. Integration with AkyosCMS

    • Embed Products in CMS Pages: Use Twig to render products (if templates are provided):
      {% for product in products %}
          <div class="product">
              <h3>{{ product.name }}</h3>
              <p>{{ product.price }} €</p>
          </div>
      {% endfor %}
      
    • Dynamic Routing: Override akyos_shop.routing in config/routes.yaml:
      akyos_shop:
          resource: "@AkyosShopBundle/Resources/config/routing.yaml"
          prefix: /shop
      

Gotchas and Tips

Pitfalls

  1. Lack of Documentation

    • Issue: No clear docs or examples for advanced features (e.g., payment gateways, shipping).
    • Workaround:
      • Inspect src/Entity/ for models and src/Service/ for business logic.
      • Check tests/ for usage patterns (if tests exist).
      • Enable debug mode (APP_DEBUG=1) and inspect generated SQL for repository methods.
  2. Proprietary License

    • Issue: License restricts commercial use without explicit permission.
    • Workaround:
      • Audit code for proprietary dependencies before production use.
      • Consider forking or extending if commercial needs arise.
  3. No Built-in Admin UI

    • Issue: Unlike "ContactForm 7 pour Symfony" (implied by README), the bundle may lack a ready-made admin panel.
    • Workaround:
      • Use Symfony’s make:crud to scaffold an admin interface:
        php bin/console make:crud Product
        
      • Integrate with EasyAdmin or SonataAdmin.
  4. CSV Dependency Quirk

    • Issue: league/csv is required but not heavily documented in the bundle.
    • Tip:
      • Use for bulk imports/exports:
        $csvReader = Reader::createFromPath('products.csv', 'r');
        $csvReader->setHeaderOffset(0);
        foreach ($csvReader as $record) {
            $product = new Product();
            $product->setName($record['name']);
            // ... map other fields
            $entityManager->persist($product);
        }
        

Debugging Tips

  1. Enable SQL Logging

    # config/packages/dev/doctrine.yaml
    doctrine:
        dbal:
            logging: true
            profiling: true
    
    • Check var/log/dev.log for raw SQL queries.
  2. Dump Entities

    use Symfony\Component\VarDumper\Cloner\VarCloner;
    use Symfony\Component\VarDumper\Dumper\HtmlDumper;
    
    $cloner = new VarCloner();
    $dumper = new HtmlDumper();
    $dumper->dump($cloner->cloneVar($product));
    
  3. Override Services

    • Extend bundle services in config/services.yaml:
      services:
          App\Service\CustomOrderManager:
              decorates: 'akyos_shop.order_manager'
              arguments: ['@App\Service\CustomOrderManager.inner']
      

Extension Points

  1. Custom Product Attributes

    • Extend the Product entity:
      namespace App\Entity;
      
      use Akyos\ShopBundle\Entity\Product as BaseProduct;
      use Doctrine\ORM\Mapping as ORM;
      
      #[ORM\Entity]
      class Product extends BaseProduct
      {
          #[ORM\Column(type: 'string', nullable: true)]
          private ?string $customAttribute = null;
      
          // Getters/setters...
      }
      
  2. Event Listeners

    • Subscribe to bundle events (if dispatched):
      namespace App\EventListener;
      
      use Akyos\ShopBundle\Event\ProductEvent;
      use Symfony\Component\EventDispatcher\Attribute\AsEventListener;
      
      class ProductListener
      {
          #[AsEventListener(event: 'akyos_shop.product.created')]
          public function onProductCreated(ProductEvent $event): void
          {
              // Logic here
          }
      }
      
  3. Payment Gateway Integration

    • Implement a custom payment service:
      namespace App\Service;
      
      use Akyos\ShopBundle\Service\PaymentInterface;
      
      class StripePaymentService implements PaymentInterface
      {
          public function processPayment(float $amount, array $orderData): bool
          {
              // Stripe logic
              return true;
          }
      }
      
    • Register as a service:
      services:
          Akyos\ShopBundle\Service\PaymentInterface: '@App\Service\StripePaymentService'
      
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.
codifyo/ts-generator-bundle
andydefer/laravel-cluster
testo/fiber
mintobit/jobqueue
a4sex/maintenance-bundle
a4sex/entity-date-update
a4sex/client-identifier
a4sex/base-utilites
a4sex/key-value-storage
a4sex/micro-status
chilldev/dependency-injection-extra
datinglibre/datinglibre-app-api
biberltd/corebundle
bricre/symfony-bundle-test
biberltd/logbundle
dominium/http-adapter-bundle
dominium/google-analytics
a4sex/auto-clean-entity
christhompsontldr/laravel-inky
spatie/mailcoach-vapor