The example that runs through this book is a real service: the Krodox License API. It’s simple enough to grasp quickly, and real enough to show the patterns that matter.
The API does one thing: it manages website licenses.
Krodox provisions websites, and every site runs on Statamic CMS, which needs a license. The moment a site is provisioned, the platform asks the License API for one. From then on, other Krodox services call this API to create, list, and revoke licenses. It is not a public API. Its consumers are Krodox’s own services and the provisioning integrations of a few partners, each identified by a token.
The License API doesn’t issue licenses itself. It asks Statamic to issue them and reshapes the answer. That detail matters for everything that follows, because it means this API has no licenses table and no License model. Its data lives behind somebody else’s HTTP API, one that can be slow, rate limited, or down.
Three license endpoints and one external provider: that is where the book starts, and it is enough to need nearly everything the book covers. Later chapters add endpoints for managing the API’s own consumers.
Krodox has other services too. One registers domain names, one manages code repositories, one generates content, one collects analytics, and a central one, the hub, provisions sites and coordinates the rest. This book stays inside the License API, but a few topics, such as slow database queries or work that spans several steps, need a bigger system to show. When an example comes from one of those sister services, the text says so, and Chapter 21 explains how they fit together.
Starting From Zero
Create a new Laravel project and tell it you are building an API:
composer create-project laravel/laravel api-license
cd api-license
php artisan install:api
install:api creates routes/api.php, registers it under the /api prefix, and installs Laravel Sanctum, which Chapter 4 uses to authenticate. (Laravel documentation: Routing › API Routes.)
That’s it. When I started with PHP, setting up a framework meant wiring configuration files and bootstrap scripts by hand before you could write a line of real code. Laravel has already made those decisions and ships them as defaults.
You are not required to keep those defaults. You can customize everything. But when you find yourself fighting the framework, that is usually a sign you are making a decision the framework was trying to save you from.