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

Ngen Bundle Laravel Package

certunlp/ngen-bundle

View on GitHub
Deep Wiki
Context7

Getting Started

Minimal Steps to Begin

  1. Installation

    composer require certunlp/ngen-bundle
    

    Add the bundle to config/bundles.php:

    return [
        // ...
        Certunlp\NgenBundle\CertunlpNgenBundle::class => ['all' => true],
    ];
    
  2. Database Migration Run the bundle’s migrations:

    php bin/console doctrine:migrations:diff
    php bin/console doctrine:migrations:migrate
    

    Check vendor/certunlp/ngen-bundle/migrations/ for schema details.

  3. First Use Case: Create an Incident Use the provided CRUD controller or create a custom one:

    use Certunlp\NgenBundle\Entity\Incident;
    use Certunlp\NgenBundle\Repository\IncidentRepository;
    
    $incident = new Incident();
    $incident->setTitle('Test Incident')
             ->setDescription('Debugging issue')
             ->setStatus('open');
    
    $entityManager->persist($incident);
    $entityManager->flush();
    
  4. Access the Admin Interface Navigate to /admin/incidents (default route) to manage incidents via the bundle’s built-in admin panel.


Implementation Patterns

Core Workflows

  1. Incident Lifecycle Management

    • Use Incident entity methods (setStatus(), setPriority()) to model workflows (e.g., openin_progressresolved).
    • Example:
      $incident->setStatus('resolved')
               ->setResolutionNotes('Fixed in v1.2.0')
               ->setResolvedAt(new \DateTime());
      
  2. Custom Fields via Extensions Extend the Incident entity to add domain-specific fields:

    namespace App\Entity;
    
    use Certunlp\NgenBundle\Entity\Incident as BaseIncident;
    use Doctrine\ORM\Mapping as ORM;
    
    #[ORM\Entity]
    class Incident extends BaseIncident
    {
        #[ORM\Column(type: 'string', length: 255, nullable: true)]
        private $customField;
    
        // Getters/setters...
    }
    
  3. Event Listeners for Automation Subscribe to bundle events (e.g., incident.status_changed) to trigger actions:

    namespace App\EventListener;
    
    use Certunlp\NgenBundle\Event\IncidentStatusChangedEvent;
    use Symfony\Component\EventDispatcher\EventSubscriberInterface;
    
    class IncidentStatusListener implements EventSubscriberInterface
    {
        public static function getSubscribedEvents(): array
        {
            return [
                IncidentStatusChangedEvent::class => 'onStatusChanged',
            ];
        }
    
        public function onStatusChanged(IncidentStatusChangedEvent $event)
        {
            if ($event->getNewStatus() === 'resolved') {
                // Send Slack notification, etc.
            }
        }
    }
    
  4. API Integration Use Symfony’s Serializer to expose incidents via API:

    # config/packages/api_platform.yaml
    api_platform:
        formats:
            jsonld: ['application/ld+json']
        resources:
            - Certunlp\NgenBundle\Entity\Incident
    
  5. Bulk Actions Leverage the IncidentRepository for batch operations:

    $repository->updateStatus(['open'], 'in_progress');
    

Integration Tips

  • Symfony Forms: Use the bundle’s IncidentType for pre-configured form fields:
    use Certunlp\NgenBundle\Form\Type\IncidentType;
    
    $form = $this->createForm(IncidentType::class, $incident);
    
  • Doctrine Filters: Apply filters to queries (e.g., active_incidents):
    $repository->createQueryBuilder('i')
                ->andWhere('i.status = :status')
                ->setParameter('status', 'open');
    
  • Translation: Override translations in translations/messages.en.yaml:
    certunlp_ngen:
        incident:
            status:
                open: "Pending Review"
    

Gotchas and Tips

Pitfalls

  1. Migration Conflicts

    • If you extend the Incident entity, run migrations after schema changes:
      php bin/console doctrine:schema:update --force
      
    • Avoid modifying bundle tables directly; use entity extensions instead.
  2. Admin Panel Overrides

    • Customize the admin panel by overriding templates in templates/bundles/certunlpngen/.
    • Example: Copy vendor/certunlp/ngen-bundle/Resources/views/admin/incident/index.html.twig to your project.
  3. Event Dispatching

    • Ensure listeners are registered in services.yaml:
      services:
          App\EventListener\IncidentStatusListener:
              tags:
                  - { name: kernel.event_subscriber }
      
  4. Performance with Large Datasets

    • Use DISTINCT in queries to avoid N+1 issues:
      $repository->createQueryBuilder('i')
                  ->select('DISTINCT i.id')
                  ->addSelect('u'); // Join with User entity
      

Debugging

  • Entity Changes Not Persisting? Verify the entity manager is flushed:
    $entityManager->flush(); // Critical after persist()!
    
  • Admin Panel Not Loading? Clear cache:
    php bin/console cache:clear
    
    Check var/log/dev.log for Twig/Doctrine errors.

Extension Points

  1. Custom Incident Types Implement Certunlp\NgenBundle\Service\IncidentTypeInterface for domain-specific logic:

    namespace App\Service;
    
    use Certunlp\NgenBundle\Service\IncidentTypeInterface;
    
    class SecurityIncidentType implements IncidentTypeInterface
    {
        public function getType(): string
        {
            return 'security';
        }
    
        public function validate(Incident $incident): bool
        {
            return $incident->getDescription()->contains('vulnerability');
        }
    }
    

    Register in services.yaml:

    services:
        App\Service\SecurityIncidentType:
            tags:
                - { name: certunlp_ngen.incident_type }
    
  2. Hooks for Pre/Post Actions Use the bundle’s IncidentLifecycleEvents to intercept actions:

    $dispatcher->dispatch(new IncidentPreCreateEvent($incident));
    
  3. Custom Validation Add constraints to extended entities:

    use Symfony\Component\Validator\Constraints as Assert;
    
    #[ORM\Entity]
    class Incident extends BaseIncident
    {
        #[Assert\Length(min: 10)]
        private $description;
    }
    

Configuration Quirks

  • Default Status Values Override in config/packages/certunlp_ngen.yaml:
    certunlp_ngen:
        default_status: 'pending' # Overrides 'open'
    
  • File Uploads Configure storage paths in config/packages/certunlp_ngen.yaml:
    certunlp_ngen:
        attachments:
            upload_dir: '%kernel.project_dir%/var/incident_attachments'
    
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.
comsave/common
alecsammon/php-raml-parser
chrome-php/wrench
lendable/composer-license-checker
typhoon/reflection
mesilov/moneyphp-percentage
mike42/gfx-php
bookdown/themes
aura/view
aura/html
aura/cli
povils/phpmnd
nayjest/manipulator
omnipay/tests
psr-mock/http-message-implementation
psr-mock/http-factory-implementation
psr-mock/http-client-implementation
voku/email-check
voku/urlify
rtheunissen/guzzle-log-middleware