28 October 2020

Introduction to Fabric

At Steadfast Collective, we’ve written quite a few Laravel packages to do things like talking to APIs and extending Laravel Cashier.

Whenever we need to create a new package, it looks something like this: find a package we already have that does a similar thing, clone it down to our machine, remove the Git repository, rename all of the Composer namespaces, remove code that’s not needed. That’s all before we can start writing code.

With that problem in mind, I set out to build something that would simplify that process, it’s called Fabric.

What it does and how it works

Fabric is a command line utility that developers can use to easily scaffold PHP, Laravel & Statamic packages.

It’s really simple to use, just specify the type of package you’d like to scaffold, eg. we specify laravel in the below example. You can specify if you’d like to enable any extra features such as a config file, routing or a facade, by passing flags as shown below. (For a full list of available parameters, review the documentation)


fabric laravel steadfastcollective/horizon-extended --config --routes --facade


Behind the scenes, the CLI is running Laravel Zero which means we can write the commands the same way you would write an artisan command in your application.

Whenever you run Fabric, it will copy the relevant stubs to the project’s folder and it will replace the namespaces from the stubs for your package.


Run this command to globally require Fabric as a Composer dependency.


composer global require steadfastcollective/fabric


For details on the usage of Fabric, visit the documentation.

Feel free to install it and give it a try. If you run into any issues, create a GitHub issue.

Duncan McClean

Web Developer at Steadfast Collective.

Share Article