Installation
1. Install the bundle
composer require makfly/stripe-cashier-bundle dompdf/dompdf:^3.1Note:
dompdf/dompdf^3.1 is installed by default (PDF renderer). You can use another renderer like Snappy (see Configuration).
To enable asynchronous webhook processing, also install:
composer require symfony/messengerThis allows Stripe events to be processed via async messages (see Events - Messenger).
2. Install ext-intl if possible
The bundle works without ext-intl, but the rendering quality of amounts and dates is better with the extension.
On Debian / Ubuntu (replace 8.x with your PHP version, e.g. 8.2, 8.3 or 8.4):
sudo apt-get install -y php8.x-intlNote: The
intlextension is recommended for monetary formatting and dates in PDF invoices.
Verification:
php -m | grep intl3. Generate the configuration
php bin/console cashier:installThe command is idempotent. It only creates what is missing.
Generated files
config/packages/cashier.yamlconfig/packages/cashier_doctrine.yamlconfig/routes/cashier.yaml.envwith missing Stripe variables
Generated directories
var/datavar/data/invoices
4. Check Stripe variables
STRIPE_KEY=pk_test_change_me
STRIPE_SECRET=sk_test_change_me
STRIPE_WEBHOOK_SECRET=whsec_change_meReplace the placeholder values before connecting to a real environment.
5. Declare a billable entity
Your entity must implement BillableEntityInterface and use BillableTrait.
use CashierBundle\Concerns\BillableTrait;
use CashierBundle\Contract\BillableEntityInterface;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity]
class User implements BillableEntityInterface
{
use BillableTrait;
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
private ?int $id = null;
#[ORM\Column(length: 180, unique: true)]
private string $email;
#[ORM\Column(length: 255, nullable: true)]
private ?string $name = null;
public function getId(): ?int
{
return $this->id;
}
public function getEmail(): string
{
return $this->email;
}
public function getName(): ?string
{
return $this->name;
}
}6. Generate migrations
php bin/console doctrine:migrations:diff
php bin/console doctrine:migrations:migrate7. Check the boot
php bin/console about
php bin/console debug:router | grep cashier
php bin/console doctrine:mapping:info8. Verify the full local installation
Prerequisite: The Stripe CLI must be installed locally to test webhooks.
php bin/console cashier:webhook:listen --forward-to=http://127.0.0.1:8000/cashier/webhookOr with --base-url to automatically build the URL:
php bin/console cashier:webhook:listen --forward-to --base-url http://localhost:8000Then trigger a test payment via Stripe Checkout to verify:
- the Checkout session
- webhook reception
- PDF generation in
var/data/invoices