Newsletter bundle for symfony 2
Newsletter bundle for Symfony 2., (*1)
Open a command console, enter your project directory and execute the following command to download the latest stable version of this bundle:, (*2)
$ composer require usn/newsletter-bundle
This command requires you to have Composer installed globally, as explained in the installation chapter of the Composer documentation., (*3)
Then, enable the bundle by adding the following line in the app/AppKernel.php
file of your project:, (*4)
<?php // app/AppKernel.php // ... class AppKernel extends Kernel { public function registerBundles() { $bundles = array( // ... new Usn\NewsletterBundle\UsnNewsletterBundle(), ); // ... } // ... }
php app/console doctrine:schema:update --force
This bundle requires jquery. Include it in the layout template., (*5)
Run the command to install js assets, (*6)
$ php app/console assets:install --symlink
Include the main.js file as below., (*7)
<script src="{{ asset('bundles/usnnewsletter/js/main.js') }}"></script>
#app/config/routing.yml usn_newsletter: resource: "@UsnNewsletterBundle/Resources/config/routing.yml"
These parameters are used when sending the confirmation email after a user register it email address., (*8)
#app/config/parameters.yml parameters: confirmation_email_subject: Your auto-reply email subject newsletter_from_address: 'no-reply@yourdomain.com' newsletter_from_name: 'Sender name'
The confirmation email templates are located herer:, (*9)
Resources/views/Default/comfirmation_email.html.twig Resources/views/Default/comfirmation_email.txt.twig
{{render(controller('UsnNewsletterBundle:Default:subscribe'))}}
The following command will send by email the number of subscribers:, (*10)
php app/console usn:newsletter:report <recipient email>