Download the PHP package betterde/voyager without Composer
On this page you can find all versions of the php package betterde/voyager. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download betterde/voyager
More information about betterde/voyager
Files in betterde/voyager
Package voyager
Short Description 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.
License MIT
Informations about the package voyager
Voyager PHP Wrapper
Voyager PHP Wrapper is a Composer package for the 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
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
- PHP 8.1 or higher
- Composer
- The 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
Build and install the C extension first:
Then enable it in your php.ini:
You can also load it temporarily for a single command:
Verify that PHP can see the extension:
Installing This Package
Install the wrapper with Composer:
For local development from this repository:
Usage
Redefine a Function
Redefine a Method
Use $this in a Redefined Method
String Body Mode
The native extension also supports defining the replacement with an argument
list string and a code body string. The Debug facade keeps that mode available.
For methods, pass optional flags as the fifth argument:
API
Betterde\Voyager\Debug::functionRedefine()
Redefines an existing function.
- Closure mode: pass a
Closureas the second argument. - String mode: pass an argument list string as the second argument and a PHP code body string as the third argument.
Betterde\Voyager\Debug::methodRedefine()
Redefines an existing class method.
Available facade flags:
| Constant | Value | Meaning |
|---|---|---|
Debug::FLAG_PUBLIC |
0x0100 |
Public method |
Debug::FLAG_PROTECTED |
0x0200 |
Protected method |
Debug::FLAG_PRIVATE |
0x0400 |
Private method |
Debug::FLAG_STATIC |
0x0001 |
Static method |
Debug::FLAG_RETURN_REFERENCE |
0x0800 |
Return by reference |
Flags may be combined with bitwise OR:
Native Functions
This package also autoloads stubs for the native functions, so IDEs and static analysis tools can understand them:
Important Notes
Voyager changes PHP runtime behavior at the Zend engine level. Treat it as a debugging, diagnostics, instrumentation, and emergency hot-fix tool.
- Redefine only functions and methods you own and understand.
- Avoid redefining code that is currently on the call stack.
- Be careful with long-running workers, preloaded code, opcache, and production traffic.
- Prefer narrow, reversible changes and add logging around live diagnostics.
- Do not use runtime redefinition as a substitute for a normal deployment flow.
Project Structure
All versions of voyager with dependencies
ext-voyager Version >=8.2.1