Installation
composer require akyos/shop-bundle
Add to config/bundles.php:
return [
// ...
Akyos\ShopBundle\AkyosShopBundle::class => ['all' => true],
];
First Use Case: Product Management
php bin/console doctrine:migrations:migrate
/admin/shop (check README for exact route).php bin/console app:shop:create-product --name="Test Product" --price=19.99
Key Configuration
Check config/packages/akyos_shop.yaml (auto-generated) for:
config/packages/akyos_shop.yaml:
akyos_shop:
default_currency: 'EUR'
tax_rate: 20
Product Management
// Example: Fetch products (if API is exposed)
$products = $this->getDoctrine()->getRepository(Product::class)->findAll();
use Akyos\ShopBundle\Entity\Product;
$product = new Product();
$product->setName('Laptop')
->setPrice(999.99)
->setSku('LP-2023');
$entityManager->persist($product);
$entityManager->flush();
Cart & Checkout
$cart = $this->get('akyos_shop.cart');
$cart->add($product, 2); // Add 2 units
$cart->isValid()).akyos_shop.payment service if available).$order = $this->get('akyos_shop.order_manager')->createOrder($cart);
Catalog & Search
$filtered = $this->getDoctrine()
->getRepository(Product::class)
->findBy(['category' => 'Electronics', 'price' => ['<=' => 500]]);
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();
Integration with AkyosCMS
{% for product in products %}
<div class="product">
<h3>{{ product.name }}</h3>
<p>{{ product.price }} €</p>
</div>
{% endfor %}
akyos_shop.routing in config/routes.yaml:
akyos_shop:
resource: "@AkyosShopBundle/Resources/config/routing.yaml"
prefix: /shop
Lack of Documentation
src/Entity/ for models and src/Service/ for business logic.tests/ for usage patterns (if tests exist).APP_DEBUG=1) and inspect generated SQL for repository methods.Proprietary License
No Built-in Admin UI
make:crud to scaffold an admin interface:
php bin/console make:crud Product
CSV Dependency Quirk
league/csv is required but not heavily documented in the bundle.$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);
}
Enable SQL Logging
# config/packages/dev/doctrine.yaml
doctrine:
dbal:
logging: true
profiling: true
var/log/dev.log for raw SQL queries.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));
Override Services
config/services.yaml:
services:
App\Service\CustomOrderManager:
decorates: 'akyos_shop.order_manager'
arguments: ['@App\Service\CustomOrderManager.inner']
Custom Product Attributes
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...
}
Event Listeners
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
}
}
Payment Gateway Integration
namespace App\Service;
use Akyos\ShopBundle\Service\PaymentInterface;
class StripePaymentService implements PaymentInterface
{
public function processPayment(float $amount, array $orderData): bool
{
// Stripe logic
return true;
}
}
services:
Akyos\ShopBundle\Service\PaymentInterface: '@App\Service\StripePaymentService'
How can I help you explore Laravel packages today?