Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/php-ffi/var-dumper
FFI types dumper extension for symfony/var-dumper package
https://github.com/php-ffi/var-dumper
Last synced: about 15 hours ago
JSON representation
FFI types dumper extension for symfony/var-dumper package
- Host: GitHub
- URL: https://github.com/php-ffi/var-dumper
- Owner: php-ffi
- License: mit
- Created: 2022-12-31T00:15:18.000Z (almost 2 years ago)
- Default Branch: master
- Last Pushed: 2024-08-14T21:02:02.000Z (3 months ago)
- Last Synced: 2024-10-21T03:03:13.497Z (17 days ago)
- Language: PHP
- Size: 18.6 KB
- Stars: 19
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# VarDumper Extension For FFI Types
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.```sh
$ composer require ffi/var-dumper
```## Usage
```php
dump(\FFI::new('struct { float x }'));//
// Expected Output:
//
// struct {
// x: 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.```php
// 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"
```