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

Directory Bundle Laravel Package

ccetc/directory-bundle

View on GitHub
Deep Wiki
Context7

Getting Started

Minimal Setup

  1. Installation

    composer require ccetc/directory-bundle
    

    Enable the bundle in config/bundles.php:

    return [
        // ...
        CCETC\DirectoryBundle\CCETCDirectoryBundle::class => ['all' => true],
    ];
    
  2. Database Migrations Run migrations to create required tables:

    php bin/console doctrine:migrations:diff
    php bin/console doctrine:migrations:migrate
    
  3. First Use Case: Basic Directory Listing

    • Create a Producer entity (if not auto-generated) extending CCETC\DirectoryBundle\Entity\Producer.
    • Register the entity in config/packages/sonata_admin.yaml:
      sonata_admin:
          options:
              models:
                  CCETC\DirectoryBundle\Entity\Producer: ~
      
    • Access the admin panel at /admin/producer to manage listings.

Implementation Patterns

Core Workflows

  1. Producer Management

    • Use Sonata Admin to CRUD producers via /admin/producer.
    • Customize fields in Producer entity (e.g., add website, logo):
      // src/Entity/Producer.php
      use CCETC\DirectoryBundle\Entity\Producer as BaseProducer;
      
      class Producer extends BaseProducer {
          /**
           * @ORM\Column(type="string", length=255, nullable=true)
           */
          private $website;
      }
      
  2. Search & Filtering

    • Leverage KnpMenu for navigation (e.g., category filters):
      {{ knp_menu_render('main_directory_menu', { depth: 1 }) }}
      
    • Implement custom search in ProducerRepository:
      public function findByLocation($location) {
          return $this->createQueryBuilder('p')
              ->where('p.location LIKE :loc')
              ->setParameter('loc', "%$location%")
              ->getQuery()
              ->getResult();
      }
      
  3. Frontend Integration

    • Display listings in Twig:
      {% for producer in producers %}
          <div class="producer-card">
              <h3>{{ producer.name }}</h3>
              <p>{{ producer.description }}</p>
              {% if producer.logo %}
                  <img src="{{ asset(producer.logo) }}" alt="{{ producer.name }}">
              {% endif %}
          </div>
      {% endfor %}
      
  4. Spam Protection

    • Configure isometriks_spam in config/packages/isometriks_spam.yaml:
      isometriks_spam:
          enabled: true
          models:
              CCETC\DirectoryBundle\Entity\Producer: ~
      

Gotchas and Tips

Pitfalls

  1. Deprecated Symfony 2.x Dependencies

    • The bundle targets Symfony 2.x (e.g., symfony/form:>=2.1,<2.3-dev). For Symfony 4/5/6:
      • Use a wrapper or fork the bundle.
      • Replace Sonata Admin with EasyAdminBundle or AdminerBundle.
    • Workaround: Override services in config/services.yaml to use modern equivalents.
  2. Missing Doctrine ORM Config

    • Ensure doctrine/orm is installed and configured in config/packages/doctrine.yaml:
      doctrine:
          orm:
              mappings:
                  ccetc_directory:
                      type: attribute
                      dir: "%kernel.project_dir%/vendor/ccetc/directory-bundle/Resources/config/doctrine"
                      prefix: 'CCETC\DirectoryBundle\Entity'
                      alias: CCETCDirectory
      
  3. Knplabs Menu Conflicts

    • If knp-menu throws errors, explicitly configure it in config/packages/knp_menu.yaml:
      knp_menu:
          twig:
              template: CCETCDirectoryBundle::menu.html.twig
      
  4. User Bundle Dependency

    • The bundle requires ccetc/directory-user-bundle (dev-master). Pin a stable version or fork:
      composer require ccetc/directory-user-bundle:dev-stable
      

Debugging Tips

  1. Admin Panel Not Loading

    • Clear cache:
      php bin/console cache:clear
      
    • Check Sonata Admin routes in config/routes/sonata_admin.yaml.
  2. Spam Bundle Errors

    • Disable temporarily in config/packages/isometriks_spam.yaml:
      isometriks_spam:
          enabled: false
      
  3. Custom Fields Not Saving

    • Ensure entity fields are properly annotated with @ORM\Column and getter/setter methods exist.

Extension Points

  1. Custom Producer Fields

    • Extend Producer entity and update Sonata Admin configuration:
      # config/packages/sonata_admin.yaml
      sonata_admin:
          options:
              models:
                  App\Entity\ExtendedProducer:
                      list:
                          fields: [name, website, logo, customField]
      
  2. Override Twig Templates

    • Copy templates from vendor/ccetc/directory-bundle/Resources/views/ to templates/CCETCDirectoryBundle/ and modify.
  3. Add Custom Categories

    • Extend the Category entity or create a new entity with a many-to-many relationship to Producer.
  4. API Endpoints

    • Use Symfony’s JsonResponse to expose producers as JSON:
      // src/Controller/ProducerController.php
      use Symfony\Component\HttpFoundation\JsonResponse;
      
      class ProducerController extends AbstractController {
          public function listProducers(): JsonResponse {
              $producers = $this->getDoctrine()->getRepository(Producer::class)->findAll();
              return new JsonResponse($producers);
          }
      }
      
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.
capell-app/block-library
axium/identity
cetria/laravel-dummy-models
cetria/reflection-helper
agropredict/sso-auth-bundle
evolvestudio/spam-protection
directorytree/privacy-filter-classifier
datacore/hub-sdk
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