Code review at scale is broken. Here’s how Augment Code is fixing it.

Laravel Spark

Published on by

Laravel Spark image

Never Miss a Laravel Release 🚀

Sign up and get an email with each new Laravel release

Please Note: This article was written when the Alpha version of Spark first released. It is no longer accurate as Spark is now a commercial project. Have a look at this Laravel Spark article for the new version.

The Alpha of Laravel Spark has just been released and its goal is to be an opinionated way of building out business oriented SaaS applications. It features team management, user roles, recurring billing through Stripe, and much more. In this tutorial let’s take a deeper look at this new package.

Spark is designed with only one goal in mind, to make scaffolding out a billing system for a SaaS app easy. If you’ve ever built out team management and a billing system then you already know how time-consuming and painful this process is. There is so much tedious work hooking up all the different systems, designing it, creating invoices, and on and on. By using Spark, you can put your focus on what matters, the business.

So let’s jump in and take a first look at Laravel Spark.

Please note that Spark is an ALPHA release. Things will change and things will break. This post is meant to give you an overview of what it features right now. As Spark stabilizes I will update this post as appropriate.

Spark Installation

The installation of Spark is straightforward by utilizing a global composer package that does all the heavy lifting. To install this open your terminal and type in:

composer global require "laravel/spark-installer=~1.0"

Next, either create a new Laravel app or go inside your existing and run:

spark install

Once this runs it will ask you a few questions from the console:

As you can see it tells you everything you need and will run all the commands for you. Of course, you can always run these commands manually with:

  • php artisan migrate
  • npm install
  • gulp

At the end of the install, it warns you to setup your Stripe tokens and an Authy key in your .env file. Authy is a two-factor authentication (2FA) system for protecting logins and you can signup for a free API key.

Now with the basic install completed let’s dive into setting it up.

SparkServiceProvider

The SparkServiceProvider handles a lot of the settings for Spark and is really powerful. Open the file and let’s go through each major section covering the basic details on what it does.

invoiceWith

The invoiceWith is used when generating email invoices for customers:

protected $invoiceWith = [
'vendor' => 'Your Company',
'product' => 'Your Product',
'street' => 'PO Box 111',
'location' => 'Your Town, 12345',
'phone' => '555-555-5555',
];

This will be one of the first things you change and should be pretty self-explanatory.

customizeSpark Method

By default all this method does is register the team model:

Spark::configure([
'models' => [
'teams' => Team::class,
]
]);

You can add other configuration, change the team model, and more.

Customize Registration and Profile Updates

The customizeRegistration and customizeProfileUpdates methods are designed to add new validation rules to these forms and/or to adjust the way users are saved. This allows you to do any custom processing.

Customize Roles

The customizeRoles integrates with Laravel 5.1.11’s new authorization feature. You can set a default role:

Spark::defaultRole('member');

Plus add your own roles:

Spark::roles([
'admin' => 'Administrator',
'member' => 'Member',
]);

Customize Settings Tabs

The customizeSettingsTabs allows you to add or remove new links in the settings forms. For example, the member settings looks like this:

![Spark Default Settings](https://i0.wp.com/d1zj60nuin5mrx.cloudfront.net/media/2015/09/16073412/spark-settings.png?resize=525%2C398&ssl=1)
Spark Default Settings
Now, if you want to add a new link you can do so by “making” a new tab under the current list:
Spark::settingsTabs()->configure(function ($tabs) {
return [
$tabs->profile(),
$tabs->teams(),
$tabs->security(),
$tabs->subscription(),
$tabs->make('My New Setting', 'test', 'fa-rocket'),
];
});

The order of parameters of $tabs->make is title, view file, icon. So in my example, I named the link “My New Setting”, created a new blade file at resources/views/test.blade.php, and used the fa-rocket icon from FontAwesome.

![New Link Added to Spark Settings](https://i2.wp.com/d1zj60nuin5mrx.cloudfront.net/media/2015/09/16073540/spark-new-settings-link.png?resize=525%2C458&ssl=1)
New Link Added to Spark Settings
You can also do the same for the tabs on the team settings page as well. It follows the same format.

Building Spark Subscription Payment Plans

Locate the customizeSubscriptionPlans method and adjust the plans to match your business needs. In this example, I created two plans with 10-day trials, that can also be purchased yearly:

Spark::plan('Basic', 'stripe-id')->price(10)
->features([
'Feature 1',
]);
Spark::plan('Advanced', 'stripe-id')->price(40)
->trialDays(7)
->features([
'Feature 1',
'Feature 2',
]);
 
Spark::plan('Basic', 'stripe-id')->price(10)
->yearly()
->features([
'Feature 1',
]);
Spark::plan('Advanced', 'stripe-id')->price(40)
->yearly()
->features([
'Feature 1',
'Feature 2',
]);

Spark really shines with the visual representation of these plans. When I added a yearly plan. The UI changed with a button to swap between monthly and yearly:

![Spark Plans](https://i1.wp.com/d1zj60nuin5mrx.cloudfront.net/media/2015/09/16074445/spark-plan.png?resize=525%2C328&ssl=1)
Spark Plans
Before a purchase can be made you will need to edit the ‘stripe-id’ and insert a real one.

Coupons and Discounts

No order system would be complete without the ability to offer customers coupons and discounts. Spark enables this in two ways.

The first is by coupons. Inside Stripe create a new one and then send your user to the register page like this:

register?coupon=10_percent

Once Spark sees the coupon in the GET request it will automatically validate it from the Stripe API and apply the discount amount to the total.

![Spark Coupon Applied](https://i0.wp.com/d1zj60nuin5mrx.cloudfront.net/media/2015/09/16075021/spark-coupon.png?resize=525%2C279&ssl=1)
Spark Coupon Applied
Site wide discounts work much the same way. The only difference is you define it in the Spark Service Provider. Inside boot() or customizeSpark() add the following:
Spark::promotion('10_percent');

Now that discount will be applied to any order.

Terms & Conditions

Create a new file named terms.md in the root of your install and it will automatically be pulled in for the /terms route. The markdown parsing is handled by Parsedown.

Closing

Spark is opinionated but very powerful. The next time you need to setup recurring billing I would recommend giving Spark a try. It will save you tons of time and effort.

Please note that Spark is an ALPHA release. Things will change and things will break. This post is meant to give you an overview of what it features right now. As Spark stabilizes I will update this post as appropriate.

Eric L. Barnes photo

Eric is the creator of Laravel News and has been covering Laravel since 2012.

Cube

Laravel Newsletter

Join 40k+ other developers and never miss out on new tips, tutorials, and more.

image
Bacancy

Outsource a dedicated Laravel developer for $3,200/month. With over a decade of experience in Laravel development, we deliver fast, high-quality, and cost-effective solutions at affordable rates.

Visit Bacancy
Curotec logo

Curotec

World class Laravel experts with GenAI dev skills. LATAM-based, embedded engineers that ship fast, communicate clearly, and elevate your product. No bloat, no BS.

Curotec
Bacancy logo

Bacancy

Supercharge your project with a seasoned Laravel developer with 4-6 years of experience for just $3200/month. Get 160 hours of dedicated expertise & a risk-free 15-day trial. Schedule a call now!

Bacancy
Tinkerwell logo

Tinkerwell

The must-have code runner for Laravel developers. Tinker with AI, autocompletion and instant feedback on local and production environments.

Tinkerwell
Cut PHP Code Review Time & Bugs into Half with CodeRabbit logo

Cut PHP Code Review Time & Bugs into Half with CodeRabbit

CodeRabbit is an AI-powered code review tool that specializes in PHP and Laravel, running PHPStan and offering automated PR analysis, security checks, and custom review features while remaining free for open-source projects.

Cut PHP Code Review Time & Bugs into Half with CodeRabbit
Get expert guidance in a few days with a Laravel code review logo

Get expert guidance in a few days with a Laravel code review

Expert code review! Get clear, practical feedback from two Laravel devs with 10+ years of experience helping teams build better apps.

Get expert guidance in a few days with a Laravel code review
Kirschbaum logo

Kirschbaum

Providing innovation and stability to ensure your web application succeeds.

Kirschbaum
Shift logo

Shift

Running an old Laravel version? Instant, automated Laravel upgrades and code modernization to keep your applications fresh.

Shift
Harpoon: Next generation time tracking and invoicing logo

Harpoon: Next generation time tracking and invoicing

The next generation time-tracking and billing software that helps your agency plan and forecast a profitable future.

Harpoon: Next generation time tracking and invoicing
Lucky Media logo

Lucky Media

Get Lucky Now - the ideal choice for Laravel Development, with over a decade of experience!

Lucky Media
Lunar: Laravel E-Commerce logo

Lunar: Laravel E-Commerce

E-Commerce for Laravel. An open-source package that brings the power of modern headless e-commerce functionality to Laravel.

Lunar: Laravel E-Commerce
SaaSykit: Laravel SaaS Starter Kit logo

SaaSykit: Laravel SaaS Starter Kit

SaaSykit is a Multi-tenant Laravel SaaS Starter Kit that comes with all features required to run a modern SaaS. Payments, Beautiful Checkout, Admin Panel, User dashboard, Auth, Ready Components, Stats, Blog, Docs and more.

SaaSykit: Laravel SaaS Starter Kit

The latest

View all →
Laravel 12.44 Adds HTTP Client afterResponse() Callbacks image

Laravel 12.44 Adds HTTP Client afterResponse() Callbacks

Read article
Handle Nested Data Structures in PHP with the Data Block Package image

Handle Nested Data Structures in PHP with the Data Block Package

Read article
Detect and Clean Up Unchanged Vendor Files with Laravel Vendor Cleanup image

Detect and Clean Up Unchanged Vendor Files with Laravel Vendor Cleanup

Read article
Seamless PropelAuth Integration in Laravel with Earhart image

Seamless PropelAuth Integration in Laravel with Earhart

Read article
Laravel API Route image

Laravel API Route

Read article
Laravel News 2025 Recap image

Laravel News 2025 Recap

Read article