Download the PHP package kappa/placeholder-processor without Composer

On this page you can find all versions of the php package kappa/placeholder-processor. 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 placeholder-processor

Kappa\PlaceholderProcessor Build Status

Easy system for working with placeholders in texts

Content

Requirements

Full list of dependencies you can get from Composer config file

Installation

The best way to install Kappa\PlaceholderProcessor is using Composer

Usages

1. step - Prepare custom placeholder processors

There is a few rules how to create a custom placeholder processors. Each you placeholder processor must implements \Kappa\PlaceholderProcessor\IPlaceholderProcessor interface or and it is recommended you can extend your class from \Kappa\PlaceholderProcessor\PlaceholderProcessor class which implements this interface and prepares logic for easy and quick usage.

For example:

This placeholder will replace %mySuperPlaceholderProcessor% placeholder by user name by id which is set as external source.

You must configure your processor in configure method. In this method you must set name of placeholder if format %<name>%. In this case this placeholder will be works with %mySuperPlaceholderProcessor% placeholder.

The second important settings is list of external sources. This list will be used for automatic compare with $source in run method. You can be sure that each of item from external source will be in $source in run method. This sources will be given from TextFormatter::format($text, $sources).

Returns from run method will be used for replacing placeholder.

2. step - Create a new instance

For translate placeholders you need instance of Kappa\PlaceholderProcessor\TextFormatter

You can create this instance manually

or you can use setPlaceholders(array) method

or when you use Nette Framework you can register this package as extension


services:
    mySuperProcessor:
        class: MySuperPlaceholderProcessor
        tags: [kappa.placeholder_processor]

extensions: 
    placeholderProcessor: Kappa\PlaceholderProcessor\DI\PlaceholderProcessorExtension

placeholderProcessor:
    strict: true

of course you can add single processor `$textFormatter->addProcessor(new MySuperPlaceholderProcessor());`.

### 3. step - Usage

Now we have custom placeholder and instance of formatter and you can try translate this text
`Hello %mySuperPlaceholderProcessor%, %foo%`

Formatter replace `%mySuperPlaceholderProcessor%` by logic in `MySuperPlaceholderProcessor` class.
This processor gets `user_id` from external source (second argument in `format` method), find
user in database and returns his name which can be used for replacing original placeholder.
Placeholder `%foo%` will be ignored because there isn't any processor with this name.

Output: `Hello Joe, %foo%`.

### Strict mode

Strict mode is turn off by default.

When you need strict mode which throws exception when in text is placeholder which hasn't any
processor (as `%foo%` in previous example). You can turn on (or off) by `setStrictMode(true)` 
method or when you use [Nette Framework](https://nette.org) in config file by `strict: true`

All versions of placeholder-processor with dependencies

PHP Build Version
Package Version
Requires php Version >= 5.4.0
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 kappa/placeholder-processor contains the following files

Loading the files please wait ....