PHPackages                             lukeraymonddowning/stubble - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. lukeraymonddowning/stubble

ActivePackage

lukeraymonddowning/stubble
==========================

A templating engine for stub files

v0.2.0(4y ago)25MITPHPPHP ^7.4|^8.0

Since Jun 1Pushed 4y agoCompare

[ Source](https://github.com/lukeraymonddowning/stubble)[ Packagist](https://packagist.org/packages/lukeraymonddowning/stubble)[ RSS](/packages/lukeraymonddowning-stubble/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (2)Dependencies (6)Versions (3)Used By (0)

Stubble
=======

[](#stubble)

A simple templating language for .stub files in Laravel projects and packages.

What is Stubble for?
--------------------

[](#what-is-stubble-for)

If you've ever built a package for Laravel, you've likely also created little `.stub` files that are published to the user's project when they run a certain command. Often, these stubs will feature dynamic content that is filled based on user input. For example, you may need to fill out a class name, or a namespace, or a filename based on the argument passed in to an Artisan command.

Usually, the *actual value* of the dynamic content is the same, but the *format* may need to change depending on its location; a filename might need to be kebab-cased, but a class name should be PascalCase. It's annoying to have to redefine all of these simple transformations to the same value just to publish a stub. What if there was a way to define these transformations *inside* the stub file? That's exactly what Stubble allows you to do.

Installation
------------

[](#installation)

You can install Stubble via Composer:

```
composer require lukeraymonddowning/stubble
```

Usage
-----

[](#usage)

Imagine you're writing an Artisan command that publishes 2 files: a class and a blade view. The class references the blade view, but we don't want the user to have to specify the name of both; the blade view filename should be automatically determined by the name of the class. Let's imagine the command looks like this:

```
php artisan make:magic MyDesiredClassName
```

You have a stub file for the class that might look like this:

```
// class.php.stub
