metacall/php-port

Call Python, C#, Ruby... functions from PHP (a PHP Port for MetaCall)

dev-master 2020-08-20 11:22 UTC

This package is not auto-updated.

Last update: 2025-07-05 09:36:15 UTC


README

M E T A C A L L

M E T A C A L L

A library for providing inter-language foreign function interface calls

Abstract

METACALL is a library that allows calling functions, methods or procedures between programming languages. With METACALL you can transparently execute code from / to any programming language, for example, call Python code from PHP.

Install

Install MetaCall binaries first (click here for additional info about the install script):

bash <(curl -sL https://raw.githubusercontent.com/metacall/install/master/install.sh)

Then install MetaCall PHP package through MetaCall:

# TODO: Composer not implemented yet in the CLI (Guix Distributable builds)
metacall composer install metacall

Example

sum.py

def sum(a, b):
  return a + b

main.php

require('metacall.php'); // Import MetaCall
require('sum.py'); // Import Python script

sum(3, 4); // 7
# TODO: PHP Loader not implemented yet
metacall main.php