Download the PHP package erebot/callable-wrapper without Composer

On this page you can find all versions of the php package erebot/callable-wrapper. 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 callable-wrapper

A DEPRECATED wrapper for the callable typehint in PHP < 5.4.0

This component is now deprecated and is unneeded in newer versions of PHP. Do not use it in new code.

Installation

Download the composer.phar executable or use the installer.

$ curl -sS https://getcomposer.org/installer | php

Create a composer.json that requires Erebot's Callable component.

{ "require": { "erebot/callable-wrapper": "dev-master" } }

Run Composer.

$ php composer.phar install

Usage

To use the wrapper, first include composer's autoloader and call Erebot\\CallableWrapper::initialize(), this will make sure everything is set up properly.

Now, use Erebot\\CallableWrapper::wrap() every time you want to execute some callable code while using the callable typehint.

How it works

This is really a two-part process.

Under the hood, the wrapper's initialize method first checks whether it is running on PHP 5.3.x or not. If it is, then Erebot\\CallableInterface gets aliased as callable in every currently-defined namespace. It also defines an autoloader which is in charge of defining that class on the fly in the current namespace when required. This is necessary for code such as the following where callable is used as a variable rather than directly as a typehint:

Since the callable typehint is only an alias to an interface, this is why you need to wrap your code using the wrap method provided, to convert your callable code into an object compatible with that interface.

This is where the magic of the wrapper's wrap method comes in. It checks whether the given code is actually callable and then identifies that code's signature (names of its arguments, which ones have default values, which ones are passed by reference etc.) It then creates a new class on the fly that implements the Erebot\\CallableInterface interface by defining an __invoke magic method with that same signature.

To speed things up a little and to avoid using too much memory, the wrap method uses a cache, where only a single class is ever created for the same code signature.

Hence, code which relies on this wrapper works the same way both on PHP 5.3.x and on later versions.

License

Erebot's Callable component is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

Erebot's Callable component is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with Erebot's Callable component. If not, see <http://www.gnu.org/licenses/>.


All versions of callable-wrapper with dependencies

PHP Build Version
Package Version
Requires php Version >=5.3.0
ext-spl Version *
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 erebot/callable-wrapper contains the following files

Loading the files please wait ....