Skip to content

FFI types dumper extension for symfony/var-dumper package

License

Notifications You must be signed in to change notification settings

php-ffi/var-dumper

Folders and files

NameName
Last commit message
Last commit date

Latest commit

77eed69 · Aug 14, 2024

History

7 Commits
Dec 31, 2022
Dec 31, 2022
Dec 31, 2022
Jan 1, 2023
Jan 1, 2023
Jan 1, 2023
Dec 31, 2022
Jan 1, 2023
Aug 14, 2024
Dec 31, 2022
Dec 31, 2022
Dec 31, 2022

Repository files navigation

VarDumper Extension For FFI Types

PHP 8.1+ Latest Stable Version Latest Unstable Version Total Downloads License MIT

This library allows you to dump FFI types using the functions dd() and dump().

Requirements

  • PHP >= 8.1

Installation

Library is available as composer repository and can be installed using the following command in a root of your project.

$ composer require ffi/var-dumper

Usage

dump(\FFI::new('struct { float x }'));

//
// Expected Output:
//
// struct <anonymous> {
//   x<float>: 0.0
// }
//

Unsafe Access

Some values may contain data that will cause access errors when read. For example, pointers leading to "emptiness".

Such data is marked as "unsafe" and only the first element is displayed. If you want to display the values in full, you should use the VAR_DUMPER_FFI_UNSAFE=1 environment variable.

// Create char* with "Hello World!\0" string.
$string = \FFI::new('char[13]');
\FFI::memcpy($string, 'Hello World!', 12);
$pointer = \FFI::cast('char*', $string);

// Dump
dump($pointer);

// VAR_DUMPER_FFI_UNSAFE=0
//
// > char* (unsafe access) {
// >  +0: "H"
// > }

// VAR_DUMPER_FFI_UNSAFE=1
//
// > b"Hello World!\x00"

About

FFI types dumper extension for symfony/var-dumper package

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages