Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mgdm/mffi
A new foreign-function interface for PHP
https://github.com/mgdm/mffi
Last synced: about 2 months ago
JSON representation
A new foreign-function interface for PHP
- Host: GitHub
- URL: https://github.com/mgdm/mffi
- Owner: mgdm
- License: mit
- Created: 2015-03-18T22:16:40.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2017-09-05T21:04:24.000Z (over 7 years ago)
- Last Synced: 2024-10-14T12:36:01.100Z (2 months ago)
- Language: C
- Homepage:
- Size: 48.8 KB
- Stars: 39
- Watchers: 13
- Forks: 5
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# MFFI
A new foreign-function interface for PHP.
## Example
```php
bind('sqrt', [MFFI\Type::TYPE_DOUBLE], MFFI\Type::TYPE_DOUBLE);
var_dump($sqrt(9)); // -> float(3.0)
```## Installing MFFI on OS X
```bash
$ brew install libffi
$ git clone https://github.com/mgdm/MFFI
$ cd MFFI
$ phpize
$ LIBFFI_PATH=$(brew --prefix libffi) LDFLAGS=" -L${LIBFFI_PATH}/lib" PKG_CONFIG_PATH="$PKG_CONFIG_PATH:${LIBFFI_PATH}/lib/pkgconfig" ./configure --with-php-config=/usr/local/bin/php-config
$ make && make install
```If everything goes well, you should see no errors and one line of output that looks something like this:
```
Installing shared extensions: /usr/local/Cellar/php70/7.0.5/lib/php/extensions/no-debug-non-zts-20151012/
```Find your loaded `php.ini` file using `php --info | grep php.ini` and add the following two lines to this file:
```bash
# The path copied from above
extension_dir=/usr/local/Cellar/php70/7.0.5/lib/php/extensions/no-debug-non-zts-20151012/
extension=mffi.so
```A successful installation can be verified by running:
```bash
php --info | grep "mffi => enabled"
```If you get the output `mffi => enabled`, you're all set!
## A word of warning
This extension is full of ways in which you can shoot yourself in the foot, except it'll take your entire leg off. It's like running with scissors, except the scissors are made of knives, and some of the knives are on fire. Be careful.