## 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],
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'
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.
Entity Data Extraction:
AccountReviewService to fetch data for a specific entity:
$reviewService = $this->container->get('account_review.service');
$data = $reviewService->getEntityData(User::class);
AccountReviewBundle\DTO\BaseEntityDTO.Export Formats:
php bin/console account-review:export --entity=App\Entity\Order --format=csv
Outputs to var/exports/orders_<timestamp>.csv.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
Integration with Controllers:
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']);
}
Scheduled Exports:
cron) to run exports nightly:
0 3 * * * php /path/to/your/project/bin/console account-review:export --entity=App\Entity\Order
Entity Mapping Issues:
Mailer Configuration:
mailer section in account_review.yaml will silently fail email exports.mailer block and validate SMTP settings in framework.yaml.File Permissions:
var/exports/ lacks write permissions.chmod -R 775 var/ or adjust permissions for the web server user.Symfony Version Quirks:
Attribute annotations) in custom DTOs due to the bundle’s Symfony 4.4+ compatibility.Log Exports: Enable debug mode to log export paths and errors:
# config/packages/dev/account_review.yaml
account_review:
debug: true
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
Command Arguments:
Use --help to inspect available options:
php bin/console account-review:export --help
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]
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 }
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);
Performance:
$queryBuilder->setMaxResults(1000);
account_review:
cache:
enabled: true
lifetime: 3600 # 1 hour
---
How can I help you explore Laravel packages today?