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

Pdd Bundle Laravel Package

common-gateway/pdd-bundle

View on GitHub
Deep Wiki
Context7

Getting Started

Minimal Steps to First Use

  1. Installation

    composer require common-gateway/pdd-bundle
    

    Add the bundle to your config/bundles.php:

    return [
        // ...
        CommonGateway\PddBundle\PddBundle::class => ['all' => true],
    ];
    
  2. Configuration Publish the default config:

    php bin/console config:dump-reference CommonGateway\PddBundle\Configuration
    

    Update config/packages/common_gateway_pdd.yaml with your OpenWoo/Open Index API credentials and endpoint URLs.

  3. First Synchronization Trigger a manual sync via CLI:

    php bin/console pdd:sync
    

    Or via a controller:

    use CommonGateway\PddBundle\Command\SyncCommand;
    $syncCommand = new SyncCommand();
    $syncCommand->run(new ArrayInput([]), new NullOutput());
    
  4. Querying Data Use the provided repository to fetch synchronized objects:

    $publication = $this->getDoctrine()
        ->getRepository(CommonGateway\PddBundle\Entity\Publication::class)
        ->findByTitle('Example Publication');
    

First Use Case: Displaying a Publication

// In a Twig template or controller
$publication = $this->getDoctrine()
    ->getRepository(CommonGateway\PddBundle\Entity\Publication::class)
    ->findOneBy(['uuid' => 'your-publication-uuid']);

return $this->render('publication/show.html.twig', [
    'publication' => $publication,
]);

Implementation Patterns

Workflows

  1. Scheduled Synchronization Use Laravel’s task scheduling to automate syncs (e.g., daily at 2 AM):

    // app/Console/Kernel.php
    protected function schedule(Schedule $schedule)
    {
        $schedule->command('pdd:sync')->dailyAt('02:00');
    }
    
  2. Event-Driven Updates Listen for sync completion events to trigger downstream actions:

    // src/EventListener/PddSyncListener.php
    namespace App\EventListener;
    
    use CommonGateway\PddBundle\Event\SyncCompletedEvent;
    use Symfony\Component\EventDispatcher\EventSubscriberInterface;
    
    class PddSyncListener implements EventSubscriberInterface
    {
        public static function getSubscribedEvents()
        {
            return [
                SyncCompletedEvent::class => 'onSyncCompleted',
            ];
        }
    
        public function onSyncCompleted(SyncCompletedEvent $event)
        {
            // Notify admins, update caches, etc.
        }
    }
    
  3. Bulk Operations Use Doctrine batch processing for large datasets:

    $em = $this->getDoctrine()->getManager();
    $publications = $em->getRepository(Publication::class)->findAll();
    
    foreach (array_chunk($publications, 50) as $chunk) {
        $em->createQueryBuilder()
            ->update(Publication::class, 'p')
            ->set('p.isProcessed', ':value')
            ->setParameter('value', true)
            ->where('p IN (:chunk)')
            ->setParameter('chunk', $chunk)
            ->getQuery()
            ->execute();
    }
    

Integration Tips

  1. Custom Fields Mapping Extend the Publication entity to include custom fields from OpenWoo:

    // src/Entity/PublicationExtension.php
    namespace App\Entity;
    
    use Doctrine\ORM\Mapping as ORM;
    use CommonGateway\PddBundle\Entity\Publication;
    
    #[ORM\Entity]
    class PublicationExtension
    {
        #[ORM\OneToOne(targetEntity: Publication::class, inversedBy: 'extension')]
        #[ORM\JoinColumn(name: 'publication_id', referencedColumnName: 'id')]
        private Publication $publication;
    
        #[ORM\Column(nullable: true)]
        private ?string $customField = null;
    
        // Getters/setters...
    }
    
  2. API Rate Limiting Configure HTTP client retries and rate limits in config/packages/common_gateway_pdd.yaml:

    clients:
        openwoo:
            timeout: 30
            retries: 3
            delay: 1000
            max_concurrency: 5
    
  3. Search Integration Use the bundle’s search service to query Open Index:

    $results = $this->get('common_gateway_pdd.search')
        ->search('query', ['category' => 'publications']);
    

Gotchas and Tips

Pitfalls

  1. UUID Conflicts

    • OpenWoo may return duplicate UUIDs during sync. Handle conflicts in your SyncCommand:
      // Override the command to merge duplicates
      $command = new SyncCommand();
      $command->setDuplicateHandler(function ($existing, $new) {
          // Custom merge logic
          return $existing;
      });
      
  2. Doctrine Mismatches

    • Ensure your database schema matches the bundle’s entities. Run migrations after installation:
      php bin/console doctrine:migrations:diff
      php bin/console doctrine:migrations:migrate
      
  3. API Deprecations

    • Monitor OpenWoo/Open Index API changes. The bundle may not auto-adapt to breaking changes. Subscribe to their changelog.

Debugging

  1. Enable Verbose Logging Add to config/packages/monolog.yaml:

    handlers:
        main:
            type: stream
            path: "%kernel.logs_dir%/%kernel.environment%.log"
            level: debug
            channels: ["!event"]
    

    Then filter for common_gateway_pdd in logs.

  2. Inspect Sync Payloads Dump raw API responses in SyncCommand:

    // In a custom command class
    $this->logger->debug('Raw API response:', [
        'response' => $client->getResponse()->getContent(),
    ]);
    
  3. Validate Entities Use Symfony’s validator to catch malformed data:

    $errors = $validator->validate($publication);
    if (count($errors) > 0) {
        throw new \RuntimeException('Validation failed: ' . (string) $errors);
    }
    

Tips

  1. Partial Syncs Use the lastSyncAt field to resume interrupted syncs:

    $lastSync = $this->getDoctrine()
        ->getRepository(Publication::class)
        ->findOneBy([], ['updatedAt' => 'DESC']);
    
    $command->setLastSyncDate($lastSync ? $lastSync->getUpdatedAt() : null);
    
  2. Webhook Integration Expose a webhook endpoint to receive real-time updates from OpenWoo:

    // src/Controller/PddWebhookController.php
    namespace App\Controller;
    
    use CommonGateway\PddBundle\Event\WebhookReceivedEvent;
    use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
    use Symfony\Component\HttpFoundation\Request;
    use Symfony\Component\HttpFoundation\Response;
    use Symfony\Component\EventDispatcher\EventDispatcherInterface;
    
    class PddWebhookController extends AbstractController
    {
        public function __invoke(Request $request, EventDispatcherInterface $dispatcher)
        {
            $dispatcher->dispatch(new WebhookReceivedEvent($request->getContent()));
            return new Response('OK');
        }
    }
    

    Route it in config/routes.yaml:

    pdd_webhook:
        path: /api/pdd/webhook
        controller: App\Controller\PddWebhookController
        methods: [POST]
    
  3. Testing Mock the HTTP client for unit tests:

    // tests/Unit/PddBundleTest.php
    use Symfony\Component\HttpClient\MockHttpClient;
    use Symfony\Component\HttpClient\Response\MockResponse;
    
    $mockClient = new MockHttpClient([
        new MockResponse('{"data": [...]}', ['http_code' => 200]),
    ]);
    
    $container->set('common_gateway_pdd.client.openwoo', $mockClient);
    
  4. Performance

    • Batch Processing: Process syncs in chunks (e.g., 100 items at a time) to avoid memory issues.
    • Async Tasks: Offload heavy syncs to a queue (e.g., Symfony Messenger or Laravel Queues):
      $message = new SyncPublicationsMessage();
      $this->messageBus->dispatch($message);
      
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.
babenkoivan/elastic-client
innmind/static-analysis
innmind/coding-standard
datacore/hub-sdk
alengo/sulu-http-cache-bundle
develia/commons
cuci/prototurk-sdk
cuci/prototurk-sdk-symfony
develia/geo-bundle
dreamzy/livewire-charts
touchestate-sdk/php-sdk
22h/doctrine-garbage-collection-bundle
agtp/agtp-php
agtp/mod-php
splash/sonata-admin
splash/metadata
splash/openapi
splash/scopes
splash/toolkit
testo/output-teamcity