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

Pmk2 Cmar Sonar Bundle Laravel Package

campusdomar/pmk2-cmar-sonar-bundle

View on GitHub
Deep Wiki
Context7

Getting Started

Minimal Setup

  1. Install via Composer

    composer require campusdomar/pmk2-cmar-sonar-bundle
    
  2. Enable the Bundle Add to config/bundles.php:

    CampusDomar\PuMuKIT2\CmarSonarBundle\CmarSonarBundle::class => ['all' => true],
    
  3. Configure the Bundle Copy default config to config/packages/cmar_sonar.yaml:

    php artisan config:dump
    

    Edit config/packages/cmar_sonar.yaml to match your PuMuKIT2 Video Platform setup.

  4. First Use Case: Sub-Portal Integration

    • Run migrations:
      php artisan doctrine:migrations:migrate
      
    • Access the sub-portal via /sonar (or configured route) to verify integration with the CMAR Web TV Portal.

Implementation Patterns

Core Workflows

  1. Sub-Portal Routing

    • Extend existing routes by defining custom routes in config/routes/cmar_sonar.yaml:
      cmar_sonar_homepage:
          path: /sonar
          controller: CampusDomar\PuMuKIT2\CmarSonarBundle\Controller\SonarController::index
      
    • Override templates in templates/cmar_sonar/ to customize UI.
  2. Data Synchronization

    • Use the bundle’s SonarService to sync content with PuMuKIT2:
      use CampusDomar\PuMuKIT2\CmarSonarBundle\Service\SonarService;
      
      $sonarService = $this->container->get(SonarService::class);
      $syncedContent = $sonarService->syncWithCmarPortal($portalId);
      
    • Schedule sync tasks via Laravel’s task scheduler (app/Console/Kernel.php):
      protected function schedule(Schedule $schedule)
      {
          $schedule->call([$this->container->get(SonarService::class), 'syncAllPortals'])
                   ->dailyAt('03:00');
      }
      
  3. Event-Driven Extensions

    • Listen to bundle events (e.g., sonar.content.synced) in your EventSubscriber:
      use CampusDomar\PuMuKIT2\CmarSonarBundle\Event\ContentSyncedEvent;
      
      public static function getSubscribedEvents()
      {
          return [
              ContentSyncedEvent::class => 'onContentSynced',
          ];
      }
      
      public function onContentSynced(ContentSyncedEvent $event)
      {
          // Custom logic (e.g., log, notify, or transform data)
      }
      
  4. API Integration

    • Use the bundle’s SonarApiClient to interact with CMAR Web TV Portal APIs:
      $apiClient = $this->container->get('cmar_sonar.api_client');
      $response = $apiClient->fetchPortalData($portalId);
      

Gotchas and Tips

Common Pitfalls

  1. Configuration Overrides

    • Ensure config/packages/cmar_sonar.yaml is properly merged with defaults. Use php artisan config:dump after changes.
    • Tip: Validate config with:
      php artisan config:validate
      
  2. Doctrine Migrations

    • The bundle includes migrations for sub-portal tables. Run them after enabling the bundle:
      php artisan doctrine:migrations:execute --up
      
    • Gotcha: Skipping migrations may cause EntityManager errors when accessing sub-portal data.
  3. Caching Quirks

    • The bundle caches synced content by default. Clear cache after manual syncs:
      php artisan cache:clear
      
    • Tip: Disable caching in config/packages/cmar_sonar.yaml for debugging:
      cache_enabled: false
      
  4. Dependency Conflicts

    • The bundle requires campusdomar/pmukit2-core-bundle. Install it first:
      composer require campusdomar/pmukit2-core-bundle
      
    • Gotcha: Version mismatches may break API calls. Pin versions in composer.json:
      "campusdomar/pmukit2-core-bundle": "2.1.*",
      "campusdomar/pmk2-cmar-sonar-bundle": "dev-main"
      
  5. Template Overrides

    • Override templates in templates/cmar_sonar/ before clearing cache to avoid stale views.
    • Tip: Use Twig’s parent() function to extend base templates:
      {% extends 'cmar_sonar/base.html.twig' %}
      {% block content %}
          {{ parent() }}
          <div class="custom-content">{{ customData }}</div>
      {% endblock %}
      
  6. Logging and Debugging

    • Enable debug mode in config/packages/cmar_sonar.yaml:
      debug: true
      
    • Check logs at var/log/cmar_sonar.log for sync errors or API issues.
  7. Extension Points

    • Custom Sync Logic: Extend SonarService by creating a decorator:
      use CampusDomar\PuMuKIT2\CmarSonarBundle\Service\SonarServiceInterface;
      
      class CustomSonarService implements SonarServiceInterface
      {
          private $decorated;
      
          public function __construct(SonarService $decorated)
          {
              $this->decorated = $decorated;
          }
      
          public function syncWithCmarPortal($portalId)
          {
              $result = $this->decorated->syncWithCmarPortal($portalId);
              // Add custom logic here
              return $result;
          }
      }
      
      Register the decorator in services.yaml:
      services:
          CampusDomar\PuMuKIT2\CmarSonarBundle\Service\SonarServiceInterface: '@custom_sonar_service'
          custom_sonar_service:
              class: App\Service\CustomSonarService
              arguments: ['@cmar_sonar.sonar_service']
      
  8. Performance

    • Batch sync operations for large portals:
      $sonarService->syncWithCmarPortal($portalId, ['batch_size' => 50]);
      
    • Tip: Monitor sync performance with Laravel Debugbar or Blackfire.

```markdown
## Documentation Note
The bundle’s `Resources/doc/` folder is the primary source of truth. For advanced use cases, refer to:
- `InstallationGuide.md` for environment setup.
- `Usage.md` for API/service details.
- `Events.md` for event-driven extensions.
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