Download the PHP package constant-null/backstubber without Composer

On this page you can find all versions of the php package constant-null/backstubber. 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 backstubber

Meet the Backstubber, the PHP file generator

GitHub license Packagist Travis

Backstubber makes generation of PHP code files from templates fast and easy. Say no to tons of str_replace.

installation

Backstubber can easily be installed using composer. To do so, just run php composer.phar require-dev constant-null/backstubber. Or you can add following to your composer.json file:

and then run:

Usage

FileGenerator

Basic substitution

Let's say we have a DummyStarship.stub template

Where $captain supposed to be a string, $officers an array and $crew is numeric. Well, just give required data to the backstubber using set() method!

The first parameter in the set() method is the string which needs to be replaced in template file, while the second is variable needs to be inserted. Backstubber will insert values according to they types, so in output we'll have something like that:

But sometimes we need to insert the variable as it is, in case of Class or Namespace name for example. For this purpose Backstubber has the setRaw() method. This method has the same signature, but recieve only strings. Lets update previous example:

So in result file EnterpriseClass.php will contain the following:

Using prefixes

If you using the same prefix for all your placeholders (just like "Dummy" prefix in example above), you can use withPrefix method. So the following code and the one shown above, will have the same results.

Templates with delimiters

Using the basic text substitution with or without prefixes like "Dummy" as in the example above is good, but sometimes you might want to specify parts to be replaced more explicitly. And this is where delimiters shows up!

Let's use the Laravel Blade style delimiters "{{" and "}}" for example, then our template file will looks like this:

And now we just tell the backstubber to use our delimiters

And this is it!

Multi-line arrays

Starting from version 0.3.0 the backstubber has support of multi-line array formatting.

With default settings associative arrays will be formatted using multi-line format and non-associative arrays using single-line format (just like in the examples shown above), so the following:

will result in:

Default behaviour can be changed using ConstantNull\Backstubber\Utility\Formatter::setArrayMode. For now, method accepts one of three parameters, which is:

  1. Formatter::ARR_MODE_AUTO for default behaviour
  2. Formatter::ARR_MODE_MULTILINE force backstabber to format all arrays in multi-line format
  3. Formatter::ARR_MODE_SINGLELINE force backstabber to format all arrays in single-line format

Authors

This library was developed by me, Mark Belotskiy. Special thanks (as promised) to my friend [Dmitriy Shulgin]() for helping with the name of the library.


All versions of backstubber with dependencies

PHP Build Version
Package Version
Requires php Version >=5.4.0
illuminate/support Version ^5.2
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 constant-null/backstubber contains the following files

Loading the files please wait ....