Home / Blog / Software Development
Software Development

Scaffold a Laravel package in one command with `laravel package`

PublishedJul 22 · 2026
Read3 min
Views0
laravel php laravel-installer package-development developer-tools
Share
Scaffold a Laravel package in one command with `laravel package`

Laravel Installer 5.31.0 adds a first-party `laravel package` command that scaffolds a complete, ready-to-develop package from a single line — and it's a clean-room alternative to Spatie's long-standing skeleton.

Laravel Installer 5.31.0, released on July 16, adds a small feature with a big quality-of-life payoff: a first-party laravel package command that scaffolds a complete, ready-to-develop Laravel package from a single line in your terminal.

If you've ever started a package, you know the drill — a service provider, a composer.json with the right autoloading, a test harness, static analysis, a formatter, and some kind of throwaway app to actually run your code against. It's an hour of plumbing before you write a line of the thing you actually wanted to build. The new command (PR #546 by Joe Tannenbaum) collapses that into one step.

What the command does

Run it with a name and Laravel takes it from there:

laravel package my-new-package

Under the hood the installer:

  1. Clones the official laravel/package-skeleton repository
  2. Cleans the git history so you start with a fresh repo
  3. Installs the Composer dependencies
  4. Runs the skeleton's configure.php script to personalize everything

By default it's interactive — Laravel Prompts walks you through the package name, namespace, author details, and which features you want.

What's in the skeleton

The generated package isn't a bare src/ folder. It comes wired up with the tooling a modern Laravel package is expected to ship with:

  • A service provider as the entry point
  • Pest 4 for testing, including type-coverage checks
  • Larastan for static analysis
  • Pint for code style
  • A Workbench app (Orchestra Testbench) so you can boot a real Laravel app and exercise your package end to end

Everything is configured and ready — composer test works out of the box.

Picking only the features you need

You rarely need every kind of package resource. The command lets you opt in to exactly what your package will ship, either through the interactive prompts or via flags:

FlagAdds
--configA publishable config file
--routesA routes file, loaded by the provider
--viewsA views directory and namespace
--translationsLanguage files
--migrationsDatabase migrations
--assetsPublishable front-end assets
--commandsAn Artisan command stub
--facadeA facade for your main class
--boost-skillA Laravel Boost skill

So a package that only needs config and a command is one line:

laravel package my-new-package --config --commands

Built for automation and AI agents

Because it's part of the installer, laravel package plugs into the same agent-detection flow the laravel new command already uses. Pass the metadata up front — --author-name, --author-email, --package-name, --package-name-human, --package-description, --vendor-namespace, --class-name — and combine it with the feature flags to scaffold a package with zero prompts. That makes it scriptable in CI and safe to hand to a coding agent, which gets structured JSON describing what was created instead of a stalled interactive prompt.

How it compares to Spatie's skeleton

For years, our go-to for spinning up a new Laravel package has been Spatie's excellent package-skeleton-laravel — press Use this template on GitHub, then run php configure.php. It's served us well, so the arrival of a first-party option had us curious how the two stack up. The new official skeleton is not built on top of Spatie's — it's a clean-room, first-party alternative, and the differences are worth knowing.

The biggest one is the service provider. Spatie's skeleton is built on spatie/laravel-package-tools, so your provider extends PackageServiceProvider and describes the package through a fluent configurePackage() method. The official skeleton has no such dependency: its provider extends the plain Illuminate\Support\ServiceProvider and uses the framework's own APIs directly — mergeConfigFrom(), loadRoutesFrom(), loadViewsFrom(), and standard publishing calls. It's more verbose, but there's no abstraction between you and Laravel, and nothing extra to learn.

The other difference is distribution. Spatie's is a GitHub template you copy; Laravel's is a CLI command in a tool you already have installed, with feature selection and full non-interactive support baked in. Neither is "better" — Spatie's laravel-package-tools is still a great abstraction and isn't going anywhere, and we'll happily keep reaching for it. But if you'd rather stay on vanilla framework APIs and scaffold straight from the terminal, there's now a first-party way to do it.

Getting it

The command ships with Laravel Installer 5.31.0. Update to the latest version and you're set:

composer global update laravel/installer

Then laravel package your next idea and skip straight to the interesting part.

Have a project in mind?

The same team behind these articles builds production platforms every day. Tell us what you're working on.

Let's connect [email protected]