Installation:
composer require aropixel/contact-bundle
Ensure aropixel/admin-bundle is also installed (required dependency).
Database Migration:
Run migrations to create the aropixel_contact table:
php bin/console doctrine:migrations:diff
php bin/console doctrine:migrations:migrate
Route Integration:
Include the bundle’s routes in your config/routes.yaml:
aropixel_contact:
resource: "@AropixelContactBundle/Resources/config/routes.yaml"
prefix: /admin
First Use Case:
POST /contact/submit./admin/contact.Form Submission:
ContactType or create a custom form class inheriting from Aropixel\ContactBundle\Form\ContactType.use Aropixel\ContactBundle\Form\ContactType;
class CustomContactType extends ContactType {
public function buildForm(FormBuilderInterface $builder, array $options) {
parent::buildForm($builder, $options);
$builder->add('custom_field', TextType::class);
}
}
$form = $this->createForm(CustomContactType::class, $contact);
Email Handling:
templates/AropixelContactBundle/).config/packages/aropixel_contact.yaml:
aropixel_contact:
from_email: 'contact@example.com'
to_emails: ['admin@example.com']
bcc_emails: ['backup@example.com']
Admin Integration:
AropixelAdminBundle.ContactAdmin class:
use Aropixel\ContactBundle\Admin\ContactAdmin;
class CustomContactAdmin extends ContactAdmin {
protected function configureListFields(ListMapper $listMapper) {
parent::configureListFields($listMapper);
$listMapper->add('custom_field');
}
}
Attachments:
$builder->add('attachment', FileType::class, [
'multiple' => true,
'mapped' => false,
]);
$contact->setAttachments($request->files->get('attachment'));
Missing Admin Bundle:
contact-bundle requires aropixel/admin-bundle. Install both:
composer require aropixel/admin-bundle aropixel/contact-bundle
Migration Issues:
aropixel_contact table structure. The bundle prefixes tables with aropixel_.php bin/console doctrine:schema:update --force if needed.Email Configuration:
symfony/mailer is configured in .env (e.g., MAILER_DSN=smtp://user:pass@smtp.example.com).to_emails array is empty (validate in config/packages/aropixel_contact.yaml).Twig Template Overrides:
templates/AropixelContactBundle/ to avoid updates overwriting changes.templates/AropixelContactBundle/Email/contact.html.twig
Date Sorting:
createdAt by default. Override the ContactRepository to customize sorting:
use Doctrine\ORM\EntityRepository;
class CustomContactRepository extends EntityRepository {
public function findAllSorted() {
return $this->createQueryBuilder('c')
->orderBy('c.updatedAt', 'DESC')
->getQuery()
->getResult();
}
}
Form Validation:
APP_DEBUG=1) to see form errors in the Symfony profiler.{{ form_start(form, { attr: { 'data-csrf-token': app.request.csrfToken } }) }}
Email Debugging:
Swiftmailer profiler to inspect sent emails:
php bin/console debug:container swiftmailer.mailer
tail -f var/log/dev.log | grep "Swift_Transport"
Attachment Handling:
public/uploads/).$builder->add('attachment', FileType::class, [
'constraints' => [
new File(['maxSize' => '1024k', 'mimeTypes' => ['image/jpeg']])
],
]);
Custom Fields:
Contact entity by extending it:
use Aropixel\ContactBundle\Entity\Contact;
class ExtendedContact extends Contact {
/**
* @ORM\Column(type="string", nullable=true)
*/
private $customField;
}
Event Listeners:
contact.pre_send event to modify messages before sending:
use Aropixel\ContactBundle\Event\ContactEvent;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
class ContactSubscriber implements EventSubscriberInterface {
public static function getSubscribedEvents() {
return ['contact.pre_send' => 'onContactSend'];
}
public function onContactSend(ContactEvent $event) {
$contact = $event->getContact();
$contact->setSubject('[Modified] ' . $contact->getSubject());
}
}
API Integration:
Serializer:
use Symfony\Component\Serializer\Normalizer\ObjectNormalizer;
$normalizer = new ObjectNormalizer();
$contactData = $normalizer->normalize($contact);
is_granted('ROLE_ADMIN').
How can I help you explore Laravel packages today?