Scout APM is PHP application performance monitoring designed for developers. With tracing logic that ties issues back to the line of code causing them, you can pinpoint n+1 queries, memory leaks, and other abnormalities in real time so you can knock them out and get back to building a great product. Start your free 14-day trial today and get the performance insight you need in less than 4 minutes.

Selling digital products using Laravel part 1: Intro + a tour of spatie.be

Original – by Freek Van der Herten – 5 minute read

On our Laravel powered company website we sell digital products: video courses, e-books, and software packages. Behind the scenes we use Laravel, Paddle, Vimeo, the GitHub API and a couple of other things.

We've open-sourced our site. You'll find the actual code we have deployed in the spatie-be repo on GitHub. In this blog post, I'll guide you through the code.

Get a nice glass of wine, or your favorite poison, or non-lethal drink, and let's dig in!

A tour of spatie.be

Before diving into the code, let's take a look at how our site can be used. All the products we sell are listed on the products page.

screenshot

If you try to buy anything without logging in, you'll get redirected to the login page. You can with an email address and a password. We assume that a very high percentage of our audience has a GitHub account, so we also provide to option to login via GitHub.

screenshot

After logging in, you can buy a product. Here's what you see when you press the buy button on the Mailcoach product page.

screenshot

You can enter your company VAT number there as well as a coupon code. That dialog is entirely rendered client-side by the Paddle integration. Paddle is a merchant of record. They act as a reseller. They sell our products in their name, so they are responsible for calculating taxes, generating invoices, ... - more on Paddle later in this post.

After you've bought a product, certain actions will happen. In the case of Mailcoach, a private PHP package, a license will be generated. You'll also be given access to the private GitHub repo.

screenshot

If you buy Laravel Beyond CRUD you'll be given access to a set of videos, and you can download the e-book.

Buying the Laravel Package Training will only give you access to the course videos.

screenshot

The videos of a bought course can be view on our site. We've built a beautiful environment where your progress is tracked. For each video, a few interesting links are displayed as well.

This is what you see when you click that "Videos" button in the screenshot above.

screenshot

Not all videos on our site are part of a paid course. Some videos are free, and others are exclusive for our sponsors. Here's what you see when you try to see a sponsor-exclusive video without being a sponsor.

screenshot

Next to the product pages and video section, our site also contains an open source section. Here, all our packages are listed.

screenshot

All of our packages are licensed as postcardware. This means that if you use any of them, you must send us a postcard. We've received hundreds of postcards from all over the world. Each of them is photographed and put on our virtual postcard wall, which you can see here.

screenshot

The documentation of some of our bigger packages also lives on our site. We think that looks a whole lot nicer than a regular GitHub repo. This is how that looks:

screenshot

This documentation is generated using markdown files that reside in the repositories of the corresponding packages.

Our team values consistency when working on projects. Whenever we agree on a particular practice, we write it down in our guidelines.

screenshot

Last but not least, let's take a look at our homepage. Several of my colleagues and I write regularly on our blogs. Using the RSS feeds on our blogs, we import the last written post and display it right on the homepage of spatie.be.

screenshot

Now that you know what you can do on our site and how it looks like, let's dig into the code that powers it. You can find our site's source code in this repo on GitHub.

This series is continued in part 2: Logging in using GitHub.

Stay up to date with all things Laravel, PHP, and JavaScript.

Follow me on Twitter. I regularly tweet out programming tips, and what I myself have learned in ongoing projects.

Every two weeks I send out a newsletter containing lots of interesting stuff for the modern PHP developer.

Expect quick tips & tricks, interesting tutorials, opinions and packages. Because I work with Laravel every day there is an emphasis on that framework.

Rest assured that I will only use your email address to send you the newsletter and will not use it for any other purposes.

Comments

Webmentions

Mariusz Pianowski liked on 20th October 2020
Diar liked on 19th October 2020
Omid liked on 18th October 2020
Mark Almadin liked on 18th October 2020
Alice Marie Brooks liked on 18th October 2020
Adam 🤙🏼 Mench liked on 18th October 2020
Daniel Bailey liked on 18th October 2020
Digambar Saha replied on 18th October 2020
I'd be super excited to check this out and put it to some use.🙏🏻❤️
Digambar Saha liked on 18th October 2020
Tom liked on 18th October 2020
Chris liked on 18th October 2020
Sumit P 🚴 liked on 18th October 2020
Mohamed Samir liked on 18th October 2020
/dev/gooners liked on 18th October 2020
Atef Rihane liked on 18th October 2020
Khai Rahman liked on 18th October 2020
Hendra Susanto liked on 17th October 2020
Daniel Lucas liked on 17th October 2020
James Smith liked on 17th October 2020
おまる liked on 17th October 2020
🤠 Alejandro Zepeda liked on 17th October 2020
Tom Zajac liked on 17th October 2020
Arslan Ramay liked on 17th October 2020
Roger Vilà liked on 17th October 2020
Jay Hughes liked on 17th October 2020
Scott Carpenter liked on 17th October 2020
Michel Tomas liked on 17th October 2020
Laurent Beauvisage liked on 17th October 2020
Luka Rasmussen liked on 17th October 2020
Steven liked on 17th October 2020
Borislav Borissov liked on 17th October 2020
Gaurav Makhecha replied on 17th October 2020
3) @spatie_be website is a Laravel app with a lot of functionality and third-party integrations. And this guy also wrote a 10-part blog series to explain how things work. unbelievably pure gold twitter.com/freekmurze/sta…
Sanjay Ahlawat liked on 17th October 2020
Silvio liked on 17th October 2020
KᖇIᔕ ᗰᗩᑎᑎIᑎG liked on 17th October 2020
Pablo liked on 17th October 2020
Benjamin Crozat liked on 17th October 2020
Adib Hanna liked on 17th October 2020
MarcoDM liked on 17th October 2020
Tiago Rodrigues liked on 17th October 2020
assoftTR liked on 17th October 2020
Dario Fuentes liked on 17th October 2020
Gerry Binns liked on 17th October 2020
Dan Petrescu liked on 17th October 2020
Joan Morell liked on 17th October 2020
José Cage liked on 17th October 2020
ceteravium liked on 16th October 2020
sunfox liked on 15th October 2020
Dickens Odera liked on 15th October 2020
Dickens Odera retweeted on 15th October 2020
sallm.in liked on 15th October 2020
Knight  liked on 15th October 2020
Daniel Grünbaum liked on 15th October 2020
Doug Black Jr 🎃👻🍬🍫 liked on 15th October 2020
Ilija Tatalovic liked on 15th October 2020
Michael Rog liked on 14th October 2020
Salman Zafar liked on 14th October 2020
Patrick Hesselberg liked on 14th October 2020
Živko Obradović liked on 14th October 2020
Aleksandar Mitić liked on 14th October 2020
TheSteed liked on 14th October 2020
FoFa liked on 14th October 2020
Patrick Hesselberg liked on 14th October 2020
Бојан Петковски liked on 14th October 2020
Diego Lorenzo liked on 14th October 2020
Jānis Lācis liked on 14th October 2020
Guus liked on 14th October 2020
Johan Alvarez liked on 14th October 2020
Songhua Hu liked on 14th October 2020
Jong Z liked on 14th October 2020
Camiant liked on 14th October 2020
Kewish Fagoe liked on 14th October 2020
Ajit Bohra liked on 14th October 2020
Flamur Mavraj liked on 14th October 2020
Remzi liked on 14th October 2020
Davis David liked on 14th October 2020
SARSMUSTEND liked on 14th October 2020
David V. liked on 14th October 2020
Oliver Davies liked on 14th October 2020
Mitchell McKenna liked on 14th October 2020
Roland liked on 14th October 2020
Jefferson liked on 14th October 2020
Aljon C Dequito liked on 14th October 2020
Alexander von Studnitz liked on 14th October 2020
Jigal Sanders liked on 14th October 2020
Alexander Hoffmann liked on 14th October 2020
danidanz 🥑 liked on 14th October 2020
Umar Jadoon liked on 14th October 2020
Neeraj Tangariya liked on 14th October 2020
Marc-André Martin liked on 14th October 2020
Tauseef shah liked on 14th October 2020
#ENDSARS #ENDSARSNOW liked on 14th October 2020
tona.castelan liked on 14th October 2020
gopibabu ⚡👨‍💻 liked on 14th October 2020
Chin Leung liked on 14th October 2020
Aung Kyaw Phyo liked on 14th October 2020
JOHN DOE liked on 14th October 2020
Eduardo Linares liked on 14th October 2020
Chris liked on 14th October 2020
Alessandro Vecchiato liked on 14th October 2020
Paulo Costa liked on 14th October 2020
Matt Haught liked on 14th October 2020
lpgfmk liked on 14th October 2020
Luigi Cruz liked on 14th October 2020
Ashley Hindle liked on 14th October 2020
Diego Lorenzo liked on 14th October 2020
Rob Mills liked on 14th October 2020
Risal Hidayat liked on 14th October 2020
Willan Correia liked on 14th October 2020
JUNO_OKYO liked on 14th October 2020
Craig Lovelock liked on 14th October 2020
Joel 🔥 liked on 14th October 2020
Fong Hok Kin liked on 14th October 2020
Wyatt liked on 14th October 2020
Simon Blonér liked on 14th October 2020
Abubakar Sadiq Umar liked on 14th October 2020
Thore Sünert liked on 14th October 2020
Petar Djurich liked on 14th October 2020
Jan Debonnet liked on 14th October 2020
Oliver Davies liked on 14th October 2020
Krom Ayε dε liked on 14th October 2020
thechile liked on 14th October 2020
Alexander Hoffmann replied on 14th October 2020
Thanks for sharing!!
Ed Ruiz 💡 replied on 14th October 2020
Super excited for this.
Ashish Dhamala liked on 14th October 2020
Alexander Maiorov liked on 14th October 2020
Al ⎋ liked on 14th October 2020
Josh Pollock liked on 14th October 2020
Andre Sayej liked on 14th October 2020
Samuel Olaegbe liked on 14th October 2020
Axel Alvarado liked on 14th October 2020
eraldgreca liked on 14th October 2020
Mariano Paz liked on 14th October 2020
Marcio; 🐘 - 433🎬 liked on 14th October 2020
Zaiman Noris liked on 14th October 2020
David Nge liked on 14th October 2020
Doug Niccum liked on 14th October 2020
Anh Tran replied on 14th October 2020
This is awesome! Thanks a lot for sharing!
lasme didier charles retweeted on 14th October 2020
barthelemy.ehui retweeted on 14th October 2020
lasme didier charles liked on 14th October 2020
lomalo42 liked on 14th October 2020
Reindert Vetter liked on 14th October 2020
Nicolas Kuster liked on 14th October 2020
Anh Tran liked on 14th October 2020
Ihor Vorotnov liked on 14th October 2020
Bartłomiej Foks liked on 14th October 2020
Oluwatobi Samuel Omisakin liked on 14th October 2020
Leonardo C Prado liked on 14th October 2020
Carlos Ufano liked on 14th October 2020
barthelemy.ehui liked on 14th October 2020
Felipe Dalcin liked on 14th October 2020
LabGeek liked on 14th October 2020
theonlyub liked on 14th October 2020
Miguel Piedrafita 🚀 liked on 14th October 2020
Bimlesh Tiwari liked on 14th October 2020
Renan Fenrich liked on 14th October 2020
Olivier Van de Velde liked on 14th October 2020
Khalid Chatar liked on 14th October 2020
Joan Morell liked on 14th October 2020
Yaroslav Khortiuk retweeted on 14th October 2020
Olivier Van de Velde retweeted on 14th October 2020
#MosiTidakPercaya liked on 14th October 2020
Renan Fenrich retweeted on 14th October 2020
Jimmy liked on 14th October 2020
🧔🏻Victor Yoalli liked on 14th October 2020
Jamie Shiers liked on 14th October 2020
oseintow liked on 14th October 2020
Kong Kimsreng liked on 14th October 2020
Niels liked on 14th October 2020
Emovon Uwadia liked on 14th October 2020
seba colombini liked on 14th October 2020
Tom Witkowski liked on 14th October 2020
Clayton Stone liked on 14th October 2020
ae liked on 14th October 2020
Sérgio Jardim replied on 14th October 2020
Awesome series of articles, thank you for posting these! Super nice to see the details, we can learn a lot.
Sérgio Jardim retweeted on 14th October 2020
Miguel Orellana retweeted on 14th October 2020
The Lloydinator liked on 14th October 2020
Asur liked on 14th October 2020
Abrar Ahmad liked on 14th October 2020
Miguel Orellana liked on 14th October 2020
Shane Beeston liked on 14th October 2020
K PradeepKumar 🚀 liked on 14th October 2020
César Ramírez liked on 14th October 2020
Hadi Swais liked on 14th October 2020
Jesil Jose liked on 14th October 2020
Aniket Mahadik liked on 14th October 2020
Christos K. liked on 14th October 2020
Yudi Purwanto liked on 14th October 2020
Marois Cyril liked on 14th October 2020
PHP Synopsis retweeted on 14th October 2020
Aleksandr retweeted on 14th October 2020
technomike retweeted on 14th October 2020
ArielMejiaDev retweeted on 14th October 2020
Brandon Adams retweeted on 14th October 2020
Nicklasos liked on 14th October 2020
mal liked on 14th October 2020
ArielMejiaDev liked on 14th October 2020
David ⚡️ liked on 14th October 2020
Shri in HK liked on 14th October 2020
Dino Pephanis liked on 14th October 2020
Aleksandr liked on 14th October 2020
Jack Watling liked on 14th October 2020
Shahram Mebashar liked on 14th October 2020
Sadegh PM liked on 14th October 2020
Mostafa A. ツ liked on 14th October 2020
Ben liked on 14th October 2020
Podcaster Dev liked on 14th October 2020
Brandon Adams liked on 14th October 2020
Don jon liked on 14th October 2020
Julien Bourdeau liked on 14th October 2020
Massimo Lusetti replied on 14th October 2020
Thank you very much... I think this is as valuable (to me even more) then every package you're releasing ...
Sanjeeva retweeted on 14th October 2020
Kim Hallberg retweeted on 14th October 2020
kronos_I retweeted on 14th October 2020
Bishoy Wagih retweeted on 14th October 2020
Jamie Peters liked on 14th October 2020
 Mario Mendoza  liked on 14th October 2020
Nam Dau liked on 14th October 2020
jfkr_ liked on 14th October 2020
Faruk Nasir liked on 14th October 2020
Muhammad Tauqeer liked on 14th October 2020
Mateus Guimarães liked on 14th October 2020
Florian Voutzinos ⚡ liked on 14th October 2020
Görkem Duymaz liked on 14th October 2020
Kim Hallberg liked on 14th October 2020
Maarten de Graaf liked on 14th October 2020
Sidrit Trandafili liked on 14th October 2020
Tawanda Moyo liked on 14th October 2020
Bishoy Wagih liked on 14th October 2020
Sanjeeva liked on 14th October 2020
Jānis Lācis liked on 14th October 2020
Waqar Zafar Tarar liked on 14th October 2020
Lars Wiegers liked on 14th October 2020
Scorp974 liked on 14th October 2020
Cody P. Christian liked on 14th October 2020
Parthasarathi G K liked on 14th October 2020
James liked on 14th October 2020
mel liked on 14th October 2020
Daan Kauwenberg liked on 14th October 2020
Bharathwaj Sriram liked on 14th October 2020
Daan Kauwenberg replied on 14th October 2020
Super om te zien dat je het open gooit en toelicht! Erg leerzaam! Thanks :)
Ross Bookmarks liked on 14th October 2020
Alexander Hoffmann liked on 14th October 2020
Axel Charpentier liked on 14th October 2020
Axel Charpentier liked on 14th October 2020
Manojkiran liked on 14th October 2020
Willan Correia liked on 14th October 2020
Bimlesh Tiwari liked on 14th October 2020
David Defoe liked on 14th October 2020
Philippe Pérusse liked on 14th October 2020
Vaibhav Pardeshi liked on 14th October 2020
Sealtyel liked on 14th October 2020
Duong Truong liked on 14th October 2020
Diego Lorenzo liked on 14th October 2020
K. E. Olivier GBLEM ⚙️ liked on 14th October 2020
Mateus liked on 14th October 2020
David Nge liked on 14th October 2020
José Cage liked on 14th October 2020
Ahmed Mohamed Abd El Ftah liked on 14th October 2020
Oanh Nguyen liked on 14th October 2020
Steve McDougall liked on 14th October 2020
Jan-Christoph Ihrens liked on 14th October 2020
salierdev liked on 14th October 2020
Dumitru Botezatu liked on 13th October 2020
Rizkhal⚡ liked on 13th October 2020
Salman Zafar liked on 13th October 2020
Rizkhal⚡ liked on 13th October 2020
Salman Zafar liked on 13th October 2020
Divan liked on 13th October 2020
Flamur Mavraj liked on 13th October 2020
Mart Dingley liked on 13th October 2020
Nii Adjetey Sowah liked on 13th October 2020
Vaibhav Pardeshi liked on 13th October 2020
Jamie Shiers liked on 13th October 2020
Michael.Chora liked on 13th October 2020
Tobias Scharikow 🦊 liked on 13th October 2020
Joan Morell liked on 13th October 2020
undefined liked on 13th October 2020
ChaoticDebris liked on 13th October 2020
Daniele Rosario liked on 13th October 2020
Leandro Ahmad liked on 13th October 2020
Ilay Almalem liked on 13th October 2020
Kaka liked on 13th October 2020
Hamid Vetr liked on 13th October 2020
PHPTrends retweeted on 13th October 2020
AlFard liked on 13th October 2020
fab liked on 13th October 2020
Omar Andrés Barbosa Ortiz liked on 13th October 2020
albert liked on 13th October 2020
Luis van den Bussche liked on 13th October 2020
Scorp974 liked on 13th October 2020
Carsten Jonstrup liked on 13th October 2020
Crowd Creativ liked on 13th October 2020
⚡404⚡ liked on 13th October 2020
/e/halil 💻🎧📌 liked on 13th October 2020
Mosh liked on 13th October 2020
Pham Tri Dung liked on 13th October 2020
Parthasarathi G K liked on 13th October 2020
smknstd liked on 13th October 2020
Bajram Emini liked on 13th October 2020
Fong Hok Kin liked on 13th October 2020
Aleksandr retweeted on 13th October 2020
miguellima retweeted on 13th October 2020
njaaazi liked on 13th October 2020
Marcio; 🐘 - 433🎬 liked on 13th October 2020
Aleksandr liked on 13th October 2020
Parthasarathi G K liked on 13th October 2020
Tareq Jobayere liked on 13th October 2020
Paddle retweeted on 13th October 2020
ArielMejiaDev retweeted on 13th October 2020
Roel Magdaleno liked on 13th October 2020
ArielMejiaDev liked on 13th October 2020
Mahmud Rafid retweeted on 13th October 2020
Oung liked on 13th October 2020
Zuzana liked on 13th October 2020
tisanomaison liked on 13th October 2020
Shamim Hossain liked on 13th October 2020
Neil Kerr liked on 13th October 2020
Crisoforo Gaspar liked on 13th October 2020
Serge Byishimo liked on 13th October 2020
Paddle liked on 13th October 2020
Marcus Olsson replied on 13th October 2020
Wow, nicely done! Must have taken a while to write =D
ArielMejiaDev retweeted on 13th October 2020
Tobias Scharikow 🦊 retweeted on 13th October 2020
Adi retweeted on 13th October 2020
Tobias Scharikow 🦊 liked on 13th October 2020
Fred Carlsen liked on 13th October 2020
ArielMejiaDev liked on 13th October 2020
Lars Wiegers liked on 13th October 2020
Felix Schmid liked on 13th October 2020
Guido Luz Percú liked on 13th October 2020
philippejadin replied on 13th October 2020
Man, this is massive! How do you still have time for client projects ? :-) (wondering the same for others Laravel *uber pedagogic* devs btw.)
Songhua Hu liked on 13th October 2020
Sérgio Jardim liked on 13th October 2020
João Oliveira retweeted on 13th October 2020
Asif Mulla retweeted on 13th October 2020
Spatie retweeted on 13th October 2020
Placebo Domingo retweeted on 13th October 2020
Ernest Chiang retweeted on 13th October 2020
DN liked on 13th October 2020
Alexander Six liked on 13th October 2020
Jesús Estévez liked on 13th October 2020
Muhammad Tauqeer liked on 13th October 2020
MrH liked on 13th October 2020
ˎˊ˗ liked on 13th October 2020
ohho liked on 13th October 2020
Mr. Alderson liked on 13th October 2020
Felix Schmid liked on 13th October 2020
Lauri Mäkinen liked on 13th October 2020
Hamid Vetr liked on 13th October 2020
Luigi Cruz liked on 13th October 2020
Ernest Chiang liked on 13th October 2020
StoicDojo liked on 13th October 2020
João Oliveira liked on 13th October 2020
Asif Mulla liked on 13th October 2020
Rezza liked on 13th October 2020
Rezza replied on 13th October 2020
So sad, vimeo blocked at indonesia
Wyatt liked on 13th October 2020
Ken V. retweeted on 13th October 2020
Wyatt retweeted on 13th October 2020
Vikas Chawla retweeted on 13th October 2020
PHP Synopsis retweeted on 13th October 2020
Noah Fleischmann liked on 13th October 2020
Rohit P. Shirke 👨‍💻 liked on 13th October 2020
Spatie retweeted on 13th October 2020
Niko Halink liked on 13th October 2020
Tauseef shah liked on 13th October 2020
Stefan Zweifel liked on 13th October 2020
ˎˊ˗ liked on 13th October 2020
Ken V. liked on 13th October 2020
ahgood liked on 13th October 2020
Robin Dirksen liked on 13th October 2020
Robin Dirksen liked on 13th October 2020
Luigi Cruz liked on 13th October 2020
Richard Radermacher liked on 13th October 2020
Aa Ezha liked on 13th October 2020
Arnoldo Garza liked on 13th October 2020
Clevon Noel🇬🇩 liked on 13th October 2020
JUNO_OKYO liked on 13th October 2020
Richard Radermacher liked on 13th October 2020
Wyatt liked on 13th October 2020
Willan Correia liked on 13th October 2020
Travis Elkins liked on 13th October 2020
Al ⎋ liked on 13th October 2020
Costas Loizou liked on 13th October 2020
Cem liked on 13th October 2020
Mozammil liked on 13th October 2020
Alain retweeted on 13th October 2020
Aniket Mahadik retweeted on 13th October 2020
Travis Elkins liked on 13th October 2020
Marc-André Martin liked on 13th October 2020
Cosmin liked on 13th October 2020
Aniket Mahadik liked on 13th October 2020
Ruben Madila liked on 13th October 2020
m@ttias ⚡️ retweeted on 13th October 2020
Borislav Borissov retweeted on 13th October 2020
Tony Messias liked on 13th October 2020
Farhan Hadi retweeted on 13th October 2020
Tobias Schulz liked on 13th October 2020
Kim Hallberg liked on 13th October 2020
m@ttias ⚡️ liked on 13th October 2020
Borislav Borissov liked on 13th October 2020
Tom de Wit liked on 13th October 2020
Nii Adjetey Sowah liked on 13th October 2020
Dixens liked on 13th October 2020
Nanderson Castro retweeted on 13th October 2020
Dries Vints 🚴‍♂️ retweeted on 13th October 2020
MOHAMED JINAS retweeted on 13th October 2020
m@ttias ⚡️ retweeted on 13th October 2020
unDev liked on 13th October 2020
Edwin I Arellano liked on 13th October 2020
Mike liked on 13th October 2020
Nanderson Castro liked on 13th October 2020
m@ttias ⚡️ liked on 13th October 2020
Dries Vints 🚴‍♂️ liked on 13th October 2020
Loris Leiva liked on 13th October 2020
Richard Vollebregt liked on 13th October 2020
Willem Van Bockstal retweeted on 13th October 2020
Christoph Rumpel 🤠 retweeted on 13th October 2020
Ahmad Abdallah retweeted on 13th October 2020
Rias Van der Veken retweeted on 13th October 2020
flowdee ツ liked on 13th October 2020
duq liked on 13th October 2020
Ian Callahan liked on 13th October 2020
Tauseef shah liked on 13th October 2020
Jeremy Gimbel liked on 13th October 2020
Chris⚡Codes🤘 liked on 13th October 2020
Davor Minchorov liked on 13th October 2020
Ahmad Abdallah liked on 13th October 2020
Gabriel Lecointere liked on 13th October 2020
its liked on 13th October 2020
Sam Tope liked on 13th October 2020
Devin Gray liked on 13th October 2020
Dan Clayton liked on 13th October 2020
Dylan Layne Tanner liked on 13th October 2020
Arash liked on 13th October 2020
Rias Van der Veken liked on 13th October 2020
Jeroen Nijhuis liked on 13th October 2020
Hadi Swais liked on 13th October 2020