PHPackages                             betterde/voyager - 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. [Debugging &amp; Profiling](/categories/debugging)
4. /
5. betterde/voyager

ActiveLibrary[Debugging &amp; Profiling](/categories/debugging)

betterde/voyager
================

A Composer package wrapper for the Voyager PHP extension, providing runtime function and method redefinition APIs for debugging, hot-fixing, instrumentation, and live system diagnostics.

8.2.1(1mo ago)07MITPHPPHP &gt;=8.1

Since May 1Pushed 1mo agoCompare

[ Source](https://github.com/betterde/voyager-php)[ Packagist](https://packagist.org/packages/betterde/voyager)[ Fund](https://betterde.github.io/ects/introduction/more.html)[ RSS](/packages/betterde-voyager/feed)WikiDiscussions master Synced 1w ago

READMEChangelog (1)DependenciesVersions (2)Used By (0)

Voyager PHP Wrapper
===================

[](#voyager-php-wrapper)

Voyager PHP Wrapper is a Composer package for the [voyager](https://github.com/betterde/voyager) PHP extension. It adds auto-loadable PHP stubs and a small object-oriented facade around the native runtime function and method redefinition APIs.

The underlying extension lives in `/Users/George/Develop/C/voyager` and provides the native functions:

- `voyager_function_redefine()`
- `voyager_method_redefine()`

This package exposes those functions to Composer projects and provides `Betterde\Voyager\Debug` for a cleaner call style.

How It Works
------------

[](#how-it-works)

 [![How Voyager replaces code with Zend HashTables](./assets/how-voyager-works.png)](./assets/how-voyager-works.png)

Features
--------

[](#features)

- Redefine existing user-defined functions at runtime.
- Redefine existing methods on user-defined classes at runtime.
- Use closures directly for replacement implementations.
- Use string argument/body mode for dynamic code generation.
- Preserve a Composer-friendly developer experience with stubs and PSR-4 autoloading.
- Provide readable flag constants for method visibility/static/reference behavior.

Requirements
------------

[](#requirements)

- PHP 8.1 or higher
- Composer
- The [voyager](https://github.com/betterde/voyager) PHP extension installed and enabled

The Composer package requires `ext-voyager`, so `composer install` will fail if the extension is not available to the PHP binary Composer is using.

Installing the Native Extension
-------------------------------

[](#installing-the-native-extension)

Build and install the C extension first:

```
git clone https://github.com/betterde/voyager
cd voyager
phpize
./configure --enable-voyager
make
make install
```

Then enable it in your `php.ini`:

```
extension=voyager
```

You can also load it temporarily for a single command:

```
php -d extension=voyager.so your-script.php
```

Verify that PHP can see the extension:

```
php -m | grep voyager
```

Installing This Package
-----------------------

[](#installing-this-package)

Install the wrapper with Composer:

```
composer require betterde/voyager
```

For local development from this repository:

```
composer install
```

Usage
-----

[](#usage)

### Redefine a Function

[](#redefine-a-function)

```
