Download the PHP package henzeb/closure without Composer

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

Closure

Build Status Latest Version on Packagist Total Downloads License

In PHP, whe have Closure::fromCallable(). Sadly, it does not work with FQCN strings.

This package ships a function that extends fromCallable allowing FQCN strings of invokable classes to become closures.

Installation

Just install with the following command.

usage

``

Resolving

Sometimes you may need to tell closure how to resolve your callable

``

Note: While closure may throw a TypeError on creation, resolving of FQCN happens on actually calling the newly created closure. Resolving happens only the first time. Except when the invokable method returns a Closure, then the resolving takes place first to return this closure.

Binding

Closures are adorable hacky little creatures due to their ability to bind and change scopes. If you ever have that need you can use bind.

``

To use a FCQN or invokable class with binding, the __invoke function must return a Closure. Please note the return type! Without, it wil fail.

``

``

Bind will under the hood use closure to get a closure, and then binds the new this and scope to it. It then returns a Closure you can use.

Calling

You can also directly call a (binded) closure using call.

``

Invoking different methods

In some cases you'd like to wrap a non-callable FQCN or class. Each function accepts a parameter named invoke.

``

``

invokable

To test an object is invokable, and thus can become a closure. The function accepts any value.

``

Wrapping

Sometimes you may expect a boolean or a callable. using closure, This would fail. Using wrap, anything that's not invokable, will be wrapped inside a closure.

``

Bindings

In some cases you might want to know the current binding of a closure or invokable.

``

accessing static variables

When you have closures that uses the use clause or when you use static variables inside your closure you can access them with the following:

``

debug info

You can use var_dump to print a list of all variables.

``

This will return an array with the current scope, the current this and any static variables associated with it.

Testing this package

Changelog

Please see CHANGELOG for more information what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email [email protected] instead of using the issue tracker.

Credits

License

The GNU AGPLv. Please see License File for more information.


All versions of closure with dependencies

PHP Build Version
Package Version
Requires php Version ^8.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 henzeb/closure contains the following files

Loading the files please wait ....