Download the PHP package klitsche/clang-ffi without Composer
On this page you can find all versions of the php package klitsche/clang-ffi. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download klitsche/clang-ffi
More information about klitsche/clang-ffi
Files in klitsche/clang-ffi
Package clang-ffi
Short Description libclang binding via ffi
License MIT
Homepage https://github.com/klitsche/clang-ffi
Informations about the package clang-ffi
clang-ffi
A library for PHP exposing libclang via FFI.
It allows easy traversing and analyzing of an abstract syntax tree of a c / c++ file.
Unfortunately PHP FFI does not currently support Struct By Value as parameter or return value in function calls. That is why a c based wrapper is provided for libclang itself, which can then be bound via FFI. This wrapper must be compiled before use.
The wrapper is taken from dart ffigen and has been slightly extended.
Expect breaking changes along all 0.* pre-releases.
Requirements
- PHP >= 7.4
- FFI extension enabled
- LLVM >= 9 with clang and libclang-dev
Quick Start
Install llvm with clang ...
... on macOS (see https://formulae.brew.sh/formula/llvm)
brew install llvm@11
... on Debian / Ubuntu (see https://apt.llvm.org/)
apt-get update; \
apt-get install wget lsb-release software-properties-common ca-certificates gnupg; \
wget -q https://apt.llvm.org/llvm.sh; \
chmod +x llvm.sh; \
sudo ./llvm.sh 11; \
apt-get install libclang-11-dev;
Install in your project
composer require klitsche/clang-ffi
Add to composer.json (this will trigger compilation of wrapped libclang library)
Dump autoload to trigger compilation
composer dump-autoload
Run examples
Checkout & prepare
git clone https://github.com/klitsche/clang-ffi.git; \
cd clang-ffi; \
docker-compose build;
Print parsed file
docker-compose run --rm php74 php examples/print.php
Collect and dump simplified AST nodes as json
docker-compose run --rm php74 php examples/json.php
Dump found issues during parsing
docker-compose run --rm php74 php examples/issues.php
Todos
- [ ] Add ffigen
- [ ] Add multiversion support for llvm >9 (some const values are different)
- [ ] Add documentation
- [ ] Add support for Windows
License
See LICENSE.md for details.
LICENSE.wrapper.c.md covers file src/FFI/libclang/wrapper.c.
All versions of clang-ffi with dependencies
ext-ffi Version *
symfony/polyfill-php80 Version ^1.20
symfony/process Version ^4.4 || ^5.0