PHPackages                             danack/fnbind - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. danack/fnbind

ActivePhp-ext[Utility &amp; Helpers](/categories/utility)

danack/fnbind
=============

Allows defining a function from a closure.

0.9.0(7mo ago)130PHPPHP &gt;=7.4

Since Oct 5Pushed 7mo agoCompare

[ Source](https://github.com/Danack/fnbind)[ Packagist](https://packagist.org/packages/danack/fnbind)[ RSS](/packages/danack-fnbind/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependenciesVersions (3)Used By (0)

[Runkit7](https://github.com/fnbind/fnbind): Independent fork of fnbind for PHP 7.2+
====================================================================================

[](#runkit7-independent-fork-of-fnbind-for-php-72)

For all those things you.... probably shouldn't have been doing anyway.... but surely do! **Supports PHP7.2-8.1!** (function/method manipulation is recommended only for unit testing, but all other functionality works.)

- Function/method manipulation crashes in PHP 7.4+ when opcache is enabled (e.g. `opcache.enable_cli`) ([Issue #217](https://github.com/fnbind/fnbind/issues/217))

    Disabling opcache is the recommended workaround.
- This has been tested with php 8.2.0beta1

[![Build Status](https://github.com/fnbind/fnbind/actions/workflows/main.yml/badge.svg?branch=master)](https://github.com/fnbind/fnbind/actions/workflows/main.yml?query=branch%3Amaster)[![Build Status (Windows)](https://camo.githubusercontent.com/9ad8e745850b1fb6d00fabf077ec238cfd20d21d343ebe44c3ca395374cdc7a2/68747470733a2f2f63692e6170707665796f722e636f6d2f6170692f70726f6a656374732f7374617475732f336a7773663736676530796f387637342f6272616e63682f6d61737465723f7376673d74727565)](https://ci.appveyor.com/project/TysonAndre/fnbind/branch/master)

[Building and installing fnbind in unix](#building-and-installing-fnbind-in-unix)

[Building and installing fnbind in Windows](#building-and-installing-fnbind-in-windows)

This extension's documentation is available at .

Compatibility: PHP7.2 to PHP 8.1
--------------------------------

[](#compatibility-php72-to-php-81)

**See [fnbind-api.php](./fnbind-api.php) for the implemented functionality and method signatures.** New functionality was added to support usage with PHP7.

- This adds the ability to set return types (including nullable return types) on added/redefined functions.
- This adds the ability to set `declare(strict_types=1)` on added/redefined functions.

Class and function manipulation is recommended only for unit tests.

- Manipulating user-defined (i.e. not builtin or part of extensions) functions and methods via `fnbind_method_*` and `fnbind_function_*` generally works, **but is recommended only in unit tests** (unlikely to crash, but will cause memory leaks)

The following contributions are welcome:

- Fixes and documentation.

#### Implemented APIs for PHP7

[](#implemented-apis-for-php7)

NOTE: Most `fnbind_*()` functions have aliases of `fnbind_*()`.

- `fnbind_function_*`: Most tests are passing. There are some memory leaks when renaming internal functions.

### FURTHER WORK

[](#further-work)

See

### Contributing

[](#contributing)

See [CONTRIBUTING.md](./CONTRIBUTING.md) for guidelines on issues and pull requests, as well as links to resources that are useful for php7 module and fnbind development.

UPSTREAM DOCUMENTATION
======================

[](#upstream-documentation)

[fnbind](https://github.com/danack/fnbind) is derived , but with most of the functionality stripped out apart from binding closure to a function name.

Features
========

[](#features)

It allows you to bind a Closure to be called as a function.

Example:

```
class Bar {
	function quux() {
		echo "Hello world!\n";
	}
}

$bar = new Bar(); $bar->quux(...);

fnbind_add_closure('foo', $bar->quux(...));

foo(); // Output is "Hello world!"

```

Because sometimes, dependency injection is overkill, but you still want to be able to configure how a function behaves.

Installation
============

[](#installation)

### BUILDING AND INSTALLING FNBIND IN UNIX

[](#building-and-installing-fnbind-in-unix)

`pecl install fnbind` can be used to install [fnbind releases published on PECL](https://pecl.php.net/package/fnbind).

Tarballs can be downloaded from [PECL](https://github.com/fnbind/fnbind/releases) or [GitHub](https://github.com/fnbind/fnbind/releases).

An example of how to build the latest master branch from source is below:

```
git clone https://github.com/fnbind/fnbind.git
cd fnbind
phpize
# The sandbox related code and flags have been removed, no need to disable them.
# (--enable-fnbind-modify (on by default) controls function, method, class, manipulation, and will control property manipulation)
# (--enable-fnbind-super (on by default) allows you to add custom superglobals)
# ./configure --help lists available configuration options.
./configure
make
make test
sudo make install
```

### BUILDING AND INSTALLING FNBIND IN WINDOWS

[](#building-and-installing-fnbind-in-windows)

#### Setting up php build environment

[](#setting-up-php-build-environment)

Read [https://wiki.php.net/internals/windows/stepbystepbuild\_sdk\_2](https://wiki.php.net/internals/windows/stepbystepbuild_sdk_2) and [https://wiki.php.net/internals/windows/stepbystepbuild\_sdk\_2#building\_pecl\_extensions](https://wiki.php.net/internals/windows/stepbystepbuild_sdk_2#building_pecl_extensions) first. This is just a special case of these instructions.

For PHP7.2+, you need to install "Visual Studio 2017 Community Edition" (or other 2017 edition). For PHP8.0+, you need to install "Visual Studio 2019 Community Edition" (or other 2019 edition). Make sure that C++ is installed with Visual Studio. The command prompt to use is "VS2017 x86 Native Tools Command Prompt" on 32-bit, "VS2017 x64 Native Tools Command Prompt" on 64-bit.

- Note that different visual studio versions are needed for different PHP versions. For PHP 8.0+, use Visual Studio 2019 and vs16 instead.

For 64-bit installations of php7, use "x64" instead of "x86" for the below commands/folders.

After completing setup steps mentioned, including for `C:\php-sdk\phpdev\vc14`

extract download of php-7.4.11-src (or any version of php 7) to C:\\php-sdk\\phpdev\\vc15\\x86\\php-7.4.11-src

#### Installing fnbind on windows

[](#installing-fnbind-on-windows)

There are currently no sources providing DLLs of this fork. Runkit7 and other extensions used must be built from source.

Create subdirectory C:\\php-sdk\\phpdev\\vc14\\x86\\pecl, adjacent to php source directory)

extract download of fnbind to C:\\php-sdk\\phpdev\\vc14\\x86\\pecl\\fnbind (all of the c files and h files should be within fnbind)

Then, execute the following (Add `--enable-fnbind` to the configure flags you were already using)

```
cd C:\php-sdk
C:\php-sdk\bin\phpsdk_setvars.bat
cd phpdev\vc15\x86\php-7.4.11\src
buildconf
configure --enable-fnbind
nmake
```

Then, optionally test it (Most of the tests should pass, be skipped, or be known failures.):

```
nmake test TESTS="C:\php-sdk\vc14\x86\pecl\fnbind\tests
```

###  Health Score

29

—

LowBetter than 59% of packages

Maintenance63

Regular maintenance activity

Popularity11

Limited adoption so far

Community15

Small or concentrated contributor base

Maturity26

Early-stage or recently created project

 Bus Factor1

Top contributor holds 70% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

225d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/9db967c6005625e444a502fb830a30669b9fed53bfbc67e81a054508c0975a6b?d=identicon)[Danack](/maintainers/Danack)

---

Top Contributors

[![TysonAndre](https://avatars.githubusercontent.com/u/1904430?v=4)](https://github.com/TysonAndre "TysonAndre (436 commits)")[![zenovich](https://avatars.githubusercontent.com/u/135378?v=4)](https://github.com/zenovich "zenovich (140 commits)")[![Danack](https://avatars.githubusercontent.com/u/1505719?v=4)](https://github.com/Danack "Danack (21 commits)")[![TysonAndre-tmg](https://avatars.githubusercontent.com/u/110992834?v=4)](https://github.com/TysonAndre-tmg "TysonAndre-tmg (10 commits)")[![tony2001](https://avatars.githubusercontent.com/u/42386?v=4)](https://github.com/tony2001 "tony2001 (7 commits)")[![TysonAndre-ContinuousIntegration](https://avatars.githubusercontent.com/u/20032915?v=4)](https://github.com/TysonAndre-ContinuousIntegration "TysonAndre-ContinuousIntegration (2 commits)")[![sgolemon](https://avatars.githubusercontent.com/u/812538?v=4)](https://github.com/sgolemon "sgolemon (2 commits)")[![nateabele](https://avatars.githubusercontent.com/u/18288?v=4)](https://github.com/nateabele "nateabele (1 commits)")[![davidsteinsland](https://avatars.githubusercontent.com/u/125661?v=4)](https://github.com/davidsteinsland "davidsteinsland (1 commits)")[![remicollet](https://avatars.githubusercontent.com/u/270445?v=4)](https://github.com/remicollet "remicollet (1 commits)")[![tototoshi](https://avatars.githubusercontent.com/u/264469?v=4)](https://github.com/tototoshi "tototoshi (1 commits)")[![egifford](https://avatars.githubusercontent.com/u/6719688?v=4)](https://github.com/egifford "egifford (1 commits)")

### Embed Badge

![Health badge](/badges/danack-fnbind/health.svg)

```
[![Health](https://phpackages.com/badges/danack-fnbind/health.svg)](https://phpackages.com/packages/danack-fnbind)
```

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
