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

Fastentitybundle Laravel Package

dotcommerce/fastentitybundle

View on GitHub
Deep Wiki
Context7

Getting Started

Minimal Steps

  1. Installation Add the bundle via Composer:

    composer require dotcommerce/fastentitybundle
    

    Register the bundle in config/bundles.php:

    return [
        // ...
        DotCommerce\FastEntityBundle\DotCommerceFastEntityBundle::class => ['all' => true],
    ];
    
  2. Generate FastEntity Form Type Run the generation command for a specific entity (e.g., Customer in StoreBundle with lastname as the dropdown field):

    php bin/console dotcommerce:generate:fastentity StoreBundle:Customer lastname
    

    This creates a new form type class (e.g., FastCustomerType) in StoreBundle/Form/FastCustomerType.php.

  3. First Use Case Use the generated form type in a Symfony form builder:

    use StoreBundle\Form\FastCustomerType;
    
    $builder->add('customer', FastCustomerType::class);
    

Implementation Patterns

Usage Patterns

  1. Bulk Generation Generate form types for all entities in a bundle (omitting EntityName):

    php bin/console dotcommerce:generate:fastentity StoreBundle
    

    Uses the name field by default if FieldName is omitted.

  2. Dynamic Dropdowns Integrate with form events to dynamically update dropdowns (e.g., cascading selects):

    $builder->addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $event) {
        $form = $event->getForm();
        $form->add('related_entity', FastRelatedEntityType::class);
    });
    
  3. Custom Querying Extend the generated form type to add custom query logic (e.g., filtering):

    // StoreBundle/Form/FastCustomerType.php
    public function configureOptions(OptionsResolver $resolver) {
        $resolver->setDefaults([
            'query_builder' => function (EntityManagerInterface $em) {
                return $em->getRepository(Customer::class)
                    ->createQueryBuilder('c')
                    ->where('c.isActive = :active')
                    ->setParameter('active', true);
            },
        ]);
    }
    
  4. Reusing in Templates Use the form type in Twig templates with custom labels/options:

    {{ form_row(form.customer, {
        'label': 'Select Customer',
        'attr': {'class': 'form-control'}
    }) }}
    

Workflows

  • Development Workflow: Regenerate form types during development if entity fields change:

    php bin/console dotcommerce:generate:fastentity StoreBundle:Customer --force
    

    (Note: --force is hypothetical; verify if supported.)

  • CI/CD Integration: Add the generation command to deployment scripts to ensure form types are up-to-date.

Integration Tips

  1. Symfony Forms: Combine with other form types (e.g., EntityType for fallback):

    $builder->add('customer', FastCustomerType::class, [
        'required' => false,
        'placeholder' => 'Select a customer...',
    ]);
    
  2. API Platform: Use the bundle for admin interfaces while keeping API endpoints clean.

  3. Doctrine Extensions: Pair with StoDoctrineExtensionsBundle for soft-deleted entities:

    // In FastCustomerType::configureOptions()
    'query_builder' => function (EntityManagerInterface $em) {
        return $em->getRepository(Customer::class)
            ->createQueryBuilder('c')
            ->where('c.deletedAt IS NULL');
    }
    

Gotchas and Tips

Pitfalls

  1. Outdated Command Syntax: The bundle is abandoned (last update: 2012). Assumptions:

    • May not work with modern Symfony (5.4+/6.x) or Doctrine (ORM 2.10+).
    • Test thoroughly in a staging environment before production use.
    • Fallback: Use Symfony’s built-in EntityType if the bundle fails.
  2. Namespace Conflicts: Generated form types (e.g., FastCustomerType) may clash with existing classes. Prefix manually:

    php bin/console dotcommerce:generate:fastentity StoreBundle:Customer lastname --prefix=Store
    

    (Note: --prefix is hypothetical; verify or rename manually.)

  3. Caching Issues: Clear cache after generation:

    php bin/console cache:clear
    
  4. Field Name Assumptions: The bundle defaults to the name field if FieldName is omitted. Override in configureOptions() if needed:

    $resolver->setDefaults([
        'choice_label' => 'email', // Custom field
    ]);
    

Debugging

  1. Command Errors: Check if the bundle’s DotCommerceFastEntityBundle is properly registered in bundles.php. Verify the entity exists in the bundle’s Resources/config/doctrine/ directory.

  2. Form Type Not Found: Ensure the generated class (e.g., FastCustomerType) is autoloaded. Run:

    composer dump-autoload
    
  3. Query Builder Failures: Debug with dd() in the generated form type’s configureOptions() to inspect the query.

Config Quirks

  1. Symfony 4+ Flex Compatibility: Manually create the Form/ directory if missing:

    mkdir -p src/StoreBundle/Form
    
  2. Doctrine Metadata: The bundle relies on Doctrine’s metadata. Ensure entities are properly mapped:

    php bin/console doctrine:schema:validate
    

Extension Points

  1. Custom Form Type Logic: Extend the generated form type to add validation or custom choices:

    public function getParent() {
        return FastCustomerType::class; // Extend the generated type
    }
    
    public function configureOptions(OptionsResolver $resolver) {
        $resolver->setDefaults([
            'choices' => $this->getCustomChoices(),
        ]);
    }
    
  2. Dynamic Choice Loading: Use choice_loader for lazy-loaded dropdowns (Symfony 4.3+):

    $builder->add('customer', FastCustomerType::class, [
        'choice_loader' => new CustomerLoader($em),
    ]);
    
  3. Event Subscribers: Listen to FormEvents::PRE_SET_DATA to modify form types dynamically:

    $formModifier->modifyForm($builder, $data);
    
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.
craftcms/url-validator
directorytree/privacy-filter-classifier
directorytree/privacy-filter
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
splash/scopes
splash/toolkit
testo/output-teamcity
testo/bridge-symfony