PHPackages                             afterflow/recipe - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. afterflow/recipe

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

afterflow/recipe
================

Laravel Generator Library

0.1.0(6y ago)91402[1 PRs](https://github.com/afterflow/recipe/pulls)2MITPHP

Since Feb 22Pushed 4y agoCompare

[ Source](https://github.com/afterflow/recipe)[ Packagist](https://packagist.org/packages/afterflow/recipe)[ RSS](/packages/afterflow-recipe/feed)WikiDiscussions master Synced 6d ago

READMEChangelogDependencies (5)Versions (4)Used By (2)

Afterflow Recipe
================

[](#afterflow-recipe)

Recipe is a generator framework built with Laravel components that allows you to generate anything based on the provided data and templates.

The primary goal of this library is to provide tooling required to create your generators.

Requirements
------------

[](#requirements)

Although it's relying on Blade templating system from Laravel Framework, this library does not require Laravel, it only pulls some of it's components.

This means you can safely include it in your own framework-agnostic composer package.

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

[](#installation)

```
composer require afterflow/recipe 0.1.*
```

Basic Usage
-----------

[](#basic-usage)

Given we have a simple Blade template:

```
{{-- templates/user.blade.php --}}

Name: {{$name}}
Last Name: {{ $last_name }}
```

Let's compile a string with Recipe:

```
$recipe = new \Afterflow\Recipe\Recipe();
$data   = $recipe->with([ 'name' => 'Vlad', 'last_name' => 'Libre' ])
                 ->template(__DIR__ . '/templates/user.blade.php')
                 ->render();
```

Returns:

```

Name: Vlad
Last Name: Libre

```

So basically we just compiled a Blade template with the given data. But that's not actually the point. Let's now see some advanced usage.

Custom Recipe classes
---------------------

[](#custom-recipe-classes)

Let's build a simple custom recipe we can reuse or even nest on other recipes. It will create a class from a stub and return the source code.

Template:

```
{{--templates/class.blade.php--}}

{{-- Otherwise this file will be treated as PHP script--}}
{!! '
