2017 © Pedro Peláez
 

library libphutil

Composer compatible version (not official) of Libphutil library.

image

mtrunkat/libphutil

Composer compatible version (not official) of Libphutil library.

  • Tuesday, May 13, 2014
  • by mtrunkat
  • Repository
  • 1 Watchers
  • 2 Stars
  • 40 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

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., (*1)

Script that I use for conversion can be found here mtrunkat/php-libphutil-composer-convertor., (*2)

For more information about Libphutil check Github repository and official documentation., (*3)

Installation

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

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

And install it via php composer.phar install or php composer.phar update., (*5)

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]., (*6)

So for example in original library you use Futures this way:, (*7)

<?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:, (*8)

<?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., (*9)

The Versions

13/05 2014

dev-master

9999999-dev https://github.com/mtrunkat/php-libphutil-composer

Composer compatible version (not official) of Libphutil library.

  Sources   Download

Apache licence

The Requires

  • php >=5.3.0

 

futures libphutil