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 Webtv Bundle Laravel Package

campusdomar/pmk2-cmar-webtv-bundle

View on GitHub
Deep Wiki
Context7

Getting Started

Minimal Setup

  1. Install via Composer Add the bundle to your composer.json:

    composer require campusdomar/pmk2-cmar-webtv-bundle
    

    Ensure CampusDomar\PuMuKIT2\CmarWebTVBundle\CmarWebTVBundle is registered in config/bundles.php:

    return [
        // ...
        CampusDomar\PuMuKIT2\CmarWebTVBundle\CmarWebTVBundle::class => ['all' => true],
    ];
    
  2. Configure the Bundle Copy the default configuration to your config/packages/cmar_webtv.yaml:

    php bin/console config:dump-reference CampusDomar\PuMuKIT2\CmarWebTVBundle\CmarWebTVBundle > config/packages/cmar_webtv.yaml
    

    Override values (e.g., branding, API endpoints) in config/packages/cmar_webtv.yaml:

    campusdomar_pumukit2_cmar_webtv:
        branding:
            logo_path: '%kernel.project_dir%/public/uploads/logos/cmar_logo.png'
            theme_color: '#2E5B8A'
        api:
            base_url: 'https://your-pumukit-api.example.com'
    
  3. First Use Case: Displaying the WebTV Portal Clear the cache and access the WebTV route (default: /webtv):

    php bin/console cache:clear
    

    The bundle extends the base PuMuKIT2/WebTVBundle with Campus do Mar’s UI. Verify the portal loads with the custom theme.


Key Files to Review

  • Resources/doc/: Official documentation (e.g., InstallationGuide.md, AdminGuide.md).
  • Resources/config/routing.yaml: WebTV routes (override if needed).
  • Resources/views/: Twig templates for customizing the UI (e.g., default/index.html.twig).

Implementation Patterns

Core Workflows

  1. Customizing the UI Override Twig templates in your project’s templates/bundles/CmarWebTV/ directory. Example:

    {# templates/bundles/CmarWebTV/default/index.html.twig #}
    {% extends 'CmarWebTVBundle:default:layout.html.twig' %}
    {% block body %}
        <div class="cmar-custom-header">
            {{ parent() }}
        </div>
    {% endblock %}
    
  2. Integrating with PuMuKIT2 API Use the bundle’s configured API endpoint (campusdomar_pumukit2_cmar_webtv.api.base_url) to fetch video metadata:

    // In a controller or service
    $apiClient = $this->container->get('cmar_webtv.api_client');
    $videos = $apiClient->get('/videos', ['limit' => 10]);
    
  3. Adding Custom Video Fields Extend the base Video entity by creating a custom form type and overriding the bundle’s VideoType:

    # config/packages/cmar_webtv.yaml
    campusdomar_pumukit2_cmar_webtv:
        video:
            custom_fields:
                - { name: 'cmar_tags', type: 'text' }
    
  4. Routing and Controllers Extend routes by creating a custom route loader:

    # config/routes/cmar_webtv.yaml
    cmar_webtv_custom:
        resource: '@CmarWebTVBundle/Resources/config/routing/custom.yaml'
        prefix: /webtv
    

    Example custom.yaml:

    cmar_webtv_playlist:
        path: /playlist/{id}
        controller: App\Controller\CmarWebTVController::playlistAction
    

Integration Tips

  • Symfony Flex: Use symfony/flex recipes to automate bundle updates.
  • Environment-Specific Config: Load different configs for dev/prod:
    # config/packages/cmar_webtv_{env}.yaml
    campusdomar_pumukit2_cmar_webtv:
         debug: {% if app.environment == 'dev' %}true{% else %}false{% endif %}
    
  • Event Listeners: Subscribe to PuMuKIT2 events (e.g., VideoUploadEvent) to trigger custom logic:
    // src/EventListener/CmarVideoListener.php
    namespace App\EventListener;
    
    use CampusDomar\PuMuKIT2\CmarWebTVBundle\Event\VideoUploadEvent;
    use Symfony\Component\EventDispatcher\EventSubscriberInterface;
    
    class CmarVideoListener implements EventSubscriberInterface {
        public static function getSubscribedEvents() {
            return [
                VideoUploadEvent::class => 'onVideoUpload',
            ];
        }
    
        public function onVideoUpload(VideoUploadEvent $event) {
            // Custom logic (e.g., log, notify)
        }
    }
    

Gotchas and Tips

Common Pitfalls

  1. Missing API Configuration

    • Symptom: Blank page or 500 error when accessing /webtv.
    • Fix: Ensure campusdomar_pumukit2_cmar_webtv.api.base_url is set correctly and the API is reachable.
    • Debug: Check Symfony logs (var/log/dev.log) for Guzzle or HttpClient errors.
  2. Template Override Conflicts

    • Symptom: Custom Twig templates are ignored.
    • Fix: Verify the override path follows Symfony’s template hierarchy:
      templates/bundles/CmarWebTV/default/ > vendor/campusdomar/pmk2-cmar-webtv-bundle/Resources/views/
      
    • Tip: Use {% debug %} in Twig to inspect loaded templates.
  3. Caching Issues

    • Symptom: Changes to templates/configs aren’t reflected.
    • Fix: Clear all caches:
      php bin/console cache:clear
      php bin/console assetic:dump --watch --env=prod
      
  4. Deprecated PuMuKIT2 Features

    • Symptom: Warnings about deprecated PuMuKIT2/WebTVBundle methods.
    • Fix: Check the PuMuKIT2 changelog and update your code accordingly.

Debugging Tips

  • Enable Debug Mode:

    # config/packages/dev/cmar_webtv.yaml
    campusdomar_pumukit2_cmar_webtv:
        debug: true
    

    This logs API requests/responses and template paths.

  • API Debugging: Use the cmar_webtv.api_client service to inspect raw responses:

    $response = $this->get('cmar_webtv.api_client')->get('/videos');
    file_put_contents('debug_api_response.json', $response->getBody());
    
  • Twig Debugging: Dump variables in templates:

    {% if app.debug %}
        {{ dump(app.request.attributes) }}
    {% endif %}
    

Extension Points

  1. Custom Video Filters Extend the VideoRepository by creating a custom service:

    // src/Service/CmarVideoFilter.php
    namespace App\Service;
    
    use CampusDomar\PuMuKIT2\CmarWebTVBundle\Repository\VideoRepository;
    
    class CmarVideoFilter extends VideoRepository {
        public function filterByCustomTag($tag) {
            // Custom logic
        }
    }
    

    Register it in services.yaml:

    services:
        App\Service\CmarVideoFilter:
            decorates: 'cmar_webtv.video_repository'
            arguments: ['@cmar_webtv.video_repository.inner']
    
  2. Custom Player Integration Override the default player by extending the PlayerType:

    {# templates/bundles/CmarWebTV/default/player.html.twig #}
    {% extends 'CmarWebTVBundle:default:player.html.twig' %}
    {% block player_script %}
        {{ parent() }}
        <script>
            // Custom player logic (e.g., Campus do Mar analytics)
        </script>
    {% endblock %}
    
  3. Webhook Integration Listen for PuMuKIT2 events to trigger external actions (e.g., Slack notifications):

    // src/EventListener/CmarWebhookListener.php
    use CampusDomar\PuMuKIT2\CmarWebTVBundle\Event\VideoUploadEvent;
    use Symfony\Component\HttpClient\HttpClient;
    
    class CmarWebhookListener {
        public function __invoke(VideoUploadEvent $event) {
            $client = HttpClient::create();
            $client->request('POST', 'https://hooks.slack.com/...', [
                'json' => ['text' => 'New video uploaded: ' . $event->getVideo()->getTitle()]
            ]);
        }
    }
    
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.
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
renatovdemoura/blade-elements-ui
devgeek/beacon-admin
benjamin-rqt/data-watcher-bundle
atriumphp/atrium