Git Product home page Git Product logo

php-libphutil-composer's Introduction

Composer compatible version of Facebook's Libphutil library

This is not offical port. I created this mainly to use Futures so the rest of the library may not work correctly.

Script that I use for conversion can be found here mtrunkat/php-libphutil-composer-convertor.

For more information about Libphutil check Github repository and official documentation.

Installation

Add this (Packagist) library into you composer.json:

{
    "require" : {
        "mtrunkat/lbphutil" : "dev-master"
    }
}

And install it via php composer.phar install or php composer.phar update.

Example use

All the classes of original library are moved into Facebook\Libphutil namespace and each function [functionname] located in some file [filename].php is converted into static method Facebook\Libphutil\Functions[filename]::[functionname].

So for example in original library you use Futures this way:

<?php
	
require_once 'path/to/libphutil/src/__phutil_library_init__.php';

$futures = array();
$futures['test a'] = new ExecFuture('ls');
$futures['test b'] = new ExecFuture('ls -l -a');
	
foreach (Futures($futures) as $dir => $future) {
    list($stdout, $stderr) = $future->resolvex();
	
    print $stdout;
}

But in Composer version of library you have to specify namespace for classes and convert functions into static methods:

<?php

require_once 'vendor/autoload.php';
	
use Facebook\Libphutil\ExecFuture;
use Facebook\Libphutil\Functions\functions;
	
$futures = array();
$futures['test a'] = new ExecFuture('ls');
$futures['test b'] = new ExecFuture('ls -l -a');
	
foreach (functions::Futures($futures) as $dir => $future) {
    list($stdout, $stderr) = $future->resolvex();
	
    print $stdout;
}

You can see that class ExecFuture in now in Facebook\Libphutil namespace and function Futures() originally located in file functions.php is now static method of class Facebook\Libphutil\Functions\functions.

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.