jeffersongoncalves/laravel-newsletter
A Laravel package for managing newsletter subscribers and mailing lists, offering simple tools to subscribe, unsubscribe, and send newsletters from your application. It integrates cleanly with Laravel's ecosystem, making email list handling and newsletter delivery straightforward and easy to configu...
composer require and run the package's install/publish step (php artisan vendor:publish for config, migrations and views), then php artisan migrate. The package ships its own tables for subscribers and tracking, so don't hand-roll a subscribers table first.php artisan route:list --path=<package-prefix>. The route list is the fastest way to confirm the middleware stack applied to the public endpoints — this is exactly what was broken in 2.0.0 and is worth verifying on every upgrade.web middleware group context. In 2.0.1+ the package routes are registered under web, so @csrf in your form is required and $errors is available in the published subscribe view. If you build your own form partial, include @csrf and render validation with @error/$errors exactly as you would for an app route.throttle, localization, or a tenant-resolution middleware on the public endpoints, append it in the package config rather than disabling the package routes and recreating them — the web group (session, cookies, CSRF) needs to stay underneath yours.auth, and don't attach middleware that assumes a logged-in user.vendor/. Publish the view namespace once, then customize the subscribe/confirm/unsubscribe templates in resources/views/vendor/.... Same for mailables if the package exposes them.$this->post(route('...subscribe'), [...])) so CSRF/session behaviour is exercised; withoutMiddleware will hide exactly the class of bug that 2.0.0 shipped with.web middleware group, so sessions, cookies, CSRF verification and $errors sharing never ran. The new subscribe form added in 2.0.0 rendered a view that referenced $errors, producing ErrorException: Undefined variable $errors on every request to it.@csrf and will start failing with TokenMismatchException. This is the fix working, not a regression — add @csrf to those forms.web onto the package route group in a service provider, you'll now get the middleware applied twice. Delete the workaround.web now applied, SameSite=Lax/Strict cookie behaviour and session startup apply to the confirm and unsubscribe routes. If you see "page expired" or lost flash messages on those endpoints, check config/session.php before suspecting the package.php artisan route:cache after changing route middleware or prefix config. Stale route caches are the most common reason a middleware change appears to do nothing.route:list to confirm web is in the stack, confirm the view is the published one (not a stale copy), confirm the session driver is reachable, and confirm @csrf is present. Those four cover nearly every report against this package's public routes.How can I help you explore Laravel packages today?