Skip to main content

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.

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.
Prerequisites: PHP 8.3+, Laravel 11 or 12, and a Polar.sh account. That’s it.
1

Install the package via Composer

Run the following command in your project root:
composer require danestves/laravel-polar
2

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:
php artisan polar:install
This command does four things:
  • Publishes config/polar.php — your Polar credentials and settings
  • Publishes database migrations for customers, subscriptions, and orders tables
  • Publishes Blade views used by the package components
  • Prompts you to run php artisan migrate right away
3

Or publish and migrate manually

If you prefer to publish assets individually, use the tagged vendor:publish commands:
# Publish migrations
php artisan vendor:publish --tag="polar-migrations"

# Publish config
php artisan vendor:publish --tag="polar-config"

# Publish views
php artisan vendor:publish --tag="polar-views"

# Run the migrations
php artisan migrate
Publishing views is optional. You only need it if you want to customise the default Blade components shipped with the package.
4

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:
->withMiddleware(function (Middleware $middleware) {
    $middleware->validateCsrfTokens(except: [
        'polar/*',
    ]);
})
Skipping this step means Polar’s webhook requests will receive a 419 Page Expired response and your database will not be updated when orders or subscriptions change.
5

Add the embed script (optional)

If you plan to use embedded checkout, include the Polar JavaScript embed script in the <head> of your layout using the @polarEmbedScript Blade directive:
<head>
    {{-- other head elements --}}

    @polarEmbedScript
</head>
This renders a <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 running polar:install and migrating, you have:
WhatWhere
Config fileconfig/polar.php
Customer tablepolar_customers
Subscriptions tablepolar_subscriptions
Orders tablepolar_orders
Blade viewsresources/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.