Weave 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

Laravel Newsletter Laravel Package

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...

View on GitHub
Deep Wiki
Context7

Getting Started

  • Install with 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.
  • Look at two files before anything else: the package config (route prefix, middleware, double opt-in toggle, view namespace) and 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.
  • First use case: a double opt-in subscribe flow. Point a plain Blade form at the package's subscribe route, submit, receive the confirmation email, click the signed link, land on the confirm route which flips the subscriber to confirmed. Once that round-trip works end to end, everything else (unsubscribe, tracking, webview) is configuration.

Implementation Patterns

  • Use the package's public routes rather than writing your own. Subscribe, confirm, unsubscribe, track and webview are all provided; duplicating them means you also inherit the job of keeping tokens, signed URLs and opt-in state consistent.
  • Forms must live inside the 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.
  • Extend middleware via config, not by re-registering routes. If you need 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.
  • Keep the tracking and webview routes unauthenticated and side-effect free. The track route is fetched by mail clients as a pixel and the webview route is opened from an email; neither has a session. Don't add auth, and don't attach middleware that assumes a logged-in user.
  • Override views through publishing, not by editing 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.
  • In tests, hit the real routes ($this->post(route('...subscribe'), [...])) so CSRF/session behaviour is exercised; withoutMiddleware will hide exactly the class of bug that 2.0.0 shipped with.

Gotchas and Tips

  • Upgrade to 2.0.1 immediately if you are on 2.0.0. The public routes were registered outside Laravel's 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.
  • Expect a 419 after upgrading if you worked around it. Because CSRF was never verified before, any custom POST form you added to the subscribe endpoint may be missing @csrf and will start failing with TokenMismatchException. This is the fix working, not a regression — add @csrf to those forms.
  • Remove manual middleware workarounds. If you patched around the bug by wrapping routes yourself, or by pushing web onto the package route group in a service provider, you'll now get the middleware applied twice. Delete the workaround.
  • Session/cookie side effects follow. Confirmation links arriving from an email client are cross-site; with 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.
  • Re-run 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.
  • Debugging checklist for "the form breaks / no validation errors show": 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.
  • Extension point to prefer: the package's route middleware config and published views. Both are upgrade-safe; subclassing controllers or editing vendor files is not, and 2.0.0→2.0.1 is a good example of why — a one-line fix upstream would have been a manual patch to maintain otherwise.
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.
roundly-consulting/kubernetes-api-for-laravel
roundly-consulting/plausible-for-laravel
gvp/gvp-laravel-template
metasyncsite/laravel-metasync-client
roundly-consulting/onboarding-for-laravel
andydefer/laravel-notification
adachsoft/cli-process-tester
jhaskell13/laraflow
sebastienheyd/boilerplate-media-manager
ccast/tagixo-primix
pretendtrue/laravel-builder
sawmainek/laravel-scout-tntsearch-driver
tomshaw/laravel-calendar-table
dibakar/laravel-ownership
steadrun/laravel-monitor
labyrinthe/connect-laravel
elmogy/layan
drewdan/sentinel-client
dskripchenko/laravel-llm
fatryst/nuonuo