Getting Laravel Polar running takes about five minutes. This page covers every step: install the package, publish assets, exempt the webhook endpoint from CSRF, and (optionally) add the embedded checkout script.Documentation Index
Fetch the complete documentation index at: https://danestvesllc-2b77d201.mintlify.app/llms.txt
Use this file to discover all available pages before exploring further.
Prerequisites: PHP 8.3+, Laravel 11 or 12, and a Polar.sh account. That’s it.
Run the install command
The package ships with an Artisan command that publishes the config file, migrations, and views in one go, then offers to run the migrations immediately:This command does four things:
- Publishes
config/polar.php— your Polar credentials and settings - Publishes database migrations for
customers,subscriptions, andorderstables - Publishes Blade views used by the package components
- Prompts you to run
php artisan migrateright away
Or publish and migrate manually
If you prefer to publish assets individually, use the tagged
vendor:publish commands:Exempt the webhook endpoint from CSRF
Polar sends webhook requests to your application from its own servers — these requests don’t carry a CSRF token. Without this step, every webhook will receive a
419 Page Expired response and your database will never update.Open bootstrap/app.php and add the exception inside withMiddleware:Add the embed script (optional)
If you plan to use embedded checkout, include the Polar JavaScript embed script in the This renders a
<head> of your layout using the @polarEmbedScript Blade directive:<script> tag that loads Polar’s checkout library, which powers the <x-polar-button> component and the data-polar-checkout attribute on links.What got installed?
After runningpolar:install and migrating, you have:
| What | Where |
|---|---|
| Config file | config/polar.php |
| Customer table | polar_customers |
| Subscriptions table | polar_subscriptions |
| Orders table | polar_orders |
| Blade views | resources/views/vendor/polar/ |
Next steps
Configuration
Set your Polar access token, webhook secret, and environment options.
Billable trait
Add the Billable trait to your User model to start creating checkouts and subscriptions.