Coder Social home page Coder Social logo

php-python-bridge's Introduction

PHP Python Bridge

Latest Version on Packagist Tests

Call your Python scripts from Php

Installation

You can install the package via composer:

composer require nikaia/php-python-bridge

Usage

The bridge work by executing a python script that accept piped json arbitary data, and returns json response.

check tests/_fixtures/ok.script.py for a working example.

use Nikaia\PythonBridge\Bridge;

try {
    $response = Bridge::create()
        ->setPython('/usr/local/bin/python')        // the path to the node (You can omit if in system path)
        ->setScript('/path/to/your/script.py')  // the path to your script 
        ->pipe(['foo' => 'bar'])                // the data to pipe to the script
        ->run();
}
catch (BridgeException $e) {
    echo $e->getMessage();
}

var_dump($response->json());   // ['foo' => 'bar']
var_dump($response->output()); // the raw output of the script {"foo":"bar"}

Changelog

Please see CHANGELOG for more information on what has changed recently.

Releases

This package use semver releases. Releases are managed using standard-version node package, and requires adhering to conventionalcommit commit styles.

  1. Implement a feature or a fix etc.
  2. Use commit message like fix: Fix an issue or feat: Implement a feature ...
  3. Or rewrite the commit message while squashing/closing the PR!!
  4. Update your local project, checkout main branch
  5. Run : composer release to generate changelog, and to tag to new release.
  6. Check everything is okay.
  7. Push the tag using git push --follow-tags origin main

This repository is using Semantic Pull Request bot to enforce conventional commit message and PR titles

Credits

License

The MIT License (MIT). Please see License File for more information.

php-python-bridge's People

Contributors

nbourguig avatar

Stargazers

Vladimir Stasiuk avatar John Ballinger avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.