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

Account Review Laravel Package

cordon/account-review

View on GitHub
Deep Wiki
Context7
## Getting Started

### Minimal Setup
1. **Installation**:
   ```bash
   composer require cordon/account-review

Enable the bundle in config/bundles.php:

Cordon\AccountReview\AccountReviewBundle::class => ['all' => true],
  1. Basic Configuration: Add the bundle to your config/packages/account_review.yaml:

    account_review:
        entities: ['App\Entity\User', 'App\Entity\Order']  # Define entities to review
        default_export_format: 'json'  # Options: 'json', 'csv', 'xml'
    
  2. First Use Case: Run the export command for a single entity:

    php bin/console account-review:export --entity=App\Entity\User --format=json
    

    Outputs a JSON file in var/exports/ with the entity data.


Implementation Patterns

Core Workflows

  1. Entity Data Extraction:

    • Use the AccountReviewService to fetch data for a specific entity:
      $reviewService = $this->container->get('account_review.service');
      $data = $reviewService->getEntityData(User::class);
      
    • Customize fields via DTOs (Data Transfer Objects) by extending AccountReviewBundle\DTO\BaseEntityDTO.
  2. Export Formats:

    • Local Export:
      php bin/console account-review:export --entity=App\Entity\Order --format=csv
      
      Outputs to var/exports/orders_<timestamp>.csv.
    • Email Export: Configure mailer in config/packages/account_review.yaml:
      account_review:
          mailer:
              enabled: true
              from_email: 'reviews@yourdomain.com'
              to_emails: ['admin@example.com']
      
      Run:
      php bin/console account-review:email --entity=App\Entity\User
      
  3. Integration with Controllers:

    • Trigger exports via API endpoints:
      use Symfony\Component\HttpFoundation\JsonResponse;
      use Cordon\AccountReviewBundle\Command\ExportCommand;
      
      public function exportData(Request $request, ExportCommand $exportCommand): JsonResponse
      {
          $entity = $request->query->get('entity');
          $exportCommand->run(new ArrayInput(['entity' => $entity]));
          return new JsonResponse(['status' => 'export_started']);
      }
      
  4. Scheduled Exports:

    • Use Symfony’s scheduler (e.g., cron) to run exports nightly:
      0 3 * * * php /path/to/your/project/bin/console account-review:export --entity=App\Entity\Order
      

Gotchas and Tips

Common Pitfalls

  1. Entity Mapping Issues:

    • If data doesn’t export as expected, verify the entity’s Doctrine mappings. The bundle relies on Doctrine’s metadata.
    • Fix: Ensure all fields are properly annotated or configured in YAML/XML mappings.
  2. Mailer Configuration:

    • Forgetting to configure the mailer section in account_review.yaml will silently fail email exports.
    • Fix: Add the mailer block and validate SMTP settings in framework.yaml.
  3. File Permissions:

    • Exports fail if var/exports/ lacks write permissions.
    • Fix: Run chmod -R 775 var/ or adjust permissions for the web server user.
  4. Symfony Version Quirks:

    • Avoid using Symfony 6.x features (e.g., Attribute annotations) in custom DTOs due to the bundle’s Symfony 4.4+ compatibility.
    • Tip: Stick to PHP 7.4+ and Symfony’s older patterns for extensions.

Debugging Tips

  1. Log Exports: Enable debug mode to log export paths and errors:

    # config/packages/dev/account_review.yaml
    account_review:
        debug: true
    
  2. Validate DTOs: If extending BaseEntityDTO, ensure methods like hydrate() and dehydrate() are correctly implemented. Test with:

    $dto = new YourCustomDTO($entity);
    $data = $dto->dehydrate(); // Check output
    
  3. Command Arguments: Use --help to inspect available options:

    php bin/console account-review:export --help
    

Extension Points

  1. Custom Exporters: Extend AccountReviewBundle\Exporter\BaseExporter to add new formats (e.g., Excel):

    namespace App\Exporter;
    
    use Cordon\AccountReviewBundle\Exporter\BaseExporter;
    
    class ExcelExporter extends BaseExporter
    {
        protected function getFileExtension(): string
        {
            return 'xlsx';
        }
    
        protected function export(array $data): string
        {
            // Use PhpSpreadsheet or similar
        }
    }
    

    Register in services.yaml:

    services:
        App\Exporter\ExcelExporter:
            tags: [account_review.exporter]
    
  2. Pre/Post-Export Hooks: Subscribe to events in services.yaml:

    services:
        App\EventListener\ExportListener:
            tags:
                - { name: kernel.event_listener, event: account_review.export.pre, method: onPreExport }
                - { name: kernel.event_listener, event: account_review.export.post, method: onPostExport }
    
  3. Dynamic Entity Selection: Override the default entity list via a compiler pass or runtime configuration:

    // In a compiler pass
    $container->setParameter('account_review.entities', $dynamicEntityList);
    
  4. Performance:

    • For large datasets, use chunking in Doctrine queries:
      $queryBuilder->setMaxResults(1000);
      
    • Cache export results if regeneration is expensive:
      account_review:
          cache:
              enabled: true
              lifetime: 3600 # 1 hour
      

---
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.
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
renatovdemoura/blade-elements-ui
devgeek/beacon-admin
benjamin-rqt/data-watcher-bundle