Download the PHP package afterflow/recipe without Composer

On this page you can find all versions of the php package afterflow/recipe. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package 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

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

Basic Usage

Given we have a simple Blade template:

Let's compile a string with Recipe:

Returns:

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

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:

Recipe:

Usage:

Few new things happen here since we are now using our own ClassRecipe class that extends Recipe. This allows us to define template inside the class and have a shorter usage syntax.

Here you can notice that we're defining a new $props variable which is somewhat similar to what VueJs uses in it's components.

First, we added some validation telling Recipe that name data property is mandatory in this recipe. You can define validation rules just like you normally would in your Laravel application - that's the same thing.

Second, we're setting default value for imports. Those defaults will be applied if the user does not provide anything as the input.

Building data without rendering

Sometimes it may be useful to only build data off of the user input and defined props without template at all:

If you call build() instead of render() you'll get back the normalized data after applying props on original input. You can use this data in other recipes to create compound generators.

Alternative syntax

A shorter syntax might be useful when building complex nested recipes.

Prepare template data before rendering

Sometimes it's useful to transform the data before sending it to Blade compiler. If your recipe has dataForTemplate() method, it's return value will be used as the data for the template.

Custom rendering

By overriding the render() method in your recipe you can create recipes without template or define any other custom rendering logic. Just make sure to call $this->build() inside to apply props to the input.

Implement Fluent API

To make process a little more fun and simple, you can sprinkle some fluency onto your recipe:

Then you can use this recipe like that:

Or use MagicSetters trait on your recipe to achieve the same functionality (this will not handle IDE highlighting though);

Nested recipes

Now let's see how powerful this can be:

Since Recipe implements __toString, you can omit render() calls here.

This will produce:

Now you can extend or nest the ClassRecipe to make a Laravel Model recipe and create a console command to generate a model or do any other crazy stuff.

Built in recipes you can use (work in progress):

Directives

Helpers

All helpers are namespaced:


All versions of recipe with dependencies

PHP Build Version
Package Version
Requires illuminate/view Version 5.*|6.*|7.*
illuminate/events Version 5.*|6.*|7.*
illuminate/filesystem Version 5.*|6.*|7.*
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package afterflow/recipe contains the following files

Loading the files please wait ....