Code Monkey home page Code Monkey logo

zombie's Introduction

Hoa

Hoa is a modular, extensible and structured set of PHP libraries. Moreover, Hoa aims at being a bridge between industrial and research worlds.

Hoa\Zombie

This library allows to transform a processus as a zombie: not alive, not dead!

This is possible only if the program is running behind PHP-FPM (which manages processus for us).

Quick usage

To create a zombie, all we have to do is to call the Hoa\Zombie\Zombie::fork method. And to kill a zombie, we have the choice between different weapons:

  • Hoa\Zombie\Zombie::decapitate, ziip;
  • Hoa\Zombie\Zombie::bludgeon, tap tap;
  • Hoa\Zombie\Zombie::burn, if you are cold;
  • Hoa\Zombie\Zombie::explode, boom;
  • Hoa\Zombie\Zombie::cutOff, sausage?

All these methods have been proven. Thus:

// I'm alive!
Hoa\Zombie\Zombie::fork();
// I'm a zombie!
Hoa\Zombie\Zombie::decapitate();
// I'm dead…

But we have to run the script behind FastCGI, that is why we will use Hoa\Fastcgi in the following example.

In the Zombie.php file, we write the following instructions:

echo 'I guess I am sick…', "\n";
Hoa\Zombie\Zombie::fork();

// Do whatever you want here, e.g.:
sleep(10);
file_put_contents(
    __DIR__ . DS . 'AMessage',
    'Hello from after-life… or somewhere about!'
);
Hoa\Zombie\Zombie::decapitate();

Then, in the Run.php file, we write:

$fastcgi = new Hoa\Fastcgi\Responder(
    new Hoa\Socket\Client('tcp://127.0.0.1:9000')
);
echo $fastcgi->send(array(
    'GATEWAY_INTERFACE' => 'FastCGI/1.0',
    'REQUEST_METHOD'    => 'GET',
    'SCRIPT_FILENAME'   => __DIR__ . DS . 'Zombie.php'
));

And finally, we can test:

$ php-fpm -d listen=127.0.0.1:9000
$ php Run.php
I guess I am sick…

And 10 seconds after, we will see the AMessage file appear with the content: Hello from after-life… or somewhere about!.

Documentation

Different documentations can be found on the website: http://hoa-project.net/.

License

Hoa is under the New BSD License (BSD-3-Clause). Please, see LICENSE.

zombie's People

Contributors

hywan avatar

Watchers

 avatar  avatar  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.