joanhey/adapterman

Use any framework and application with Workerman.

Fund package maintenance!
joanhey

Installs: 32 482

Dependents: 2

Suggesters: 0

Security: 0

Stars: 768

Watchers: 14

Forks: 51

0.6.1 2023-04-16 00:05 UTC

README

Tests Adapterman GitHub release GitHub

Faster and more scalable apps, also use it as Serverless.

Run almost any PHP app with the async event driven Workerman, without touch 1 line of code in your fw or app.

If your app or fw use a Front Controller, 99% that will work. Requires minimun PHP 8.0.

Actually working with:

  • Symfony
  • Laravel
  • CakePHP
  • Yii2
  • Slim
  • KumbiaPHP
  • ThinkPHP
  • Leaf
  • ... (Your app?)

Still testing with more fws and apps. Without touch a line of code.

NEW !!! Workerman shared nothing mode

We started to test it. Experimental still.

Each request is independent and load the .php file, like with PHP-FPM. Using the same .php files.

image

Performance bench Worker mode

Results from Techempower benchmark. Without touch a line of code.

Follow https://twitter.com/adaptermanphp for more updates.

Symfony 6

With full ORM image Latency image

Laravel 8

With full ORM.

image Latency image

Slim with Workerman

Without ORM image

  • Without ORM and db class optimized for Workerman

Symfony demo with Workerman

Symfony initialization 0ms and half the time per request.

Grabacion_microsoft-edge-dev_20221023170450.mp4

Installation

composer require joanhey/adapterman

Automatically install Workerman too.

Tree

Where to create the files (server.php and start.php)

.
├── app(dir)
├── public(dir)
├── vendor(dir)
├── composer.json
├── server.php
└── start.php

Server

server.php

<?php

require_once __DIR__ . '/vendor/autoload.php';

use Adapterman\Adapterman;
use Workerman\Worker;

Adapterman::init();

$http_worker                = new Worker('http://0.0.0.0:8080');
$http_worker->count         = 8;
$http_worker->name          = 'AdapterMan';

$http_worker->onWorkerStart = static function () {
    //init();
    require __DIR__.'/start.php';
};

$http_worker->onMessage = static function ($connection, $request) {

    $connection->send(run());
};

Worker::runAll();

Front Controller

It's different for any fw and app.

We are creating recipes for popular apps and frameworks.

Recommended start.php and leave index.php in public.

We can run the app with Workerman and with php-fpm at the same time.

Available commands in workerman

To run your app.

php server.php start
php server.php start -d
php server.php status
php server.php status -d
php server.php connections
php server.php stop
php server.php stop -g
php server.php restart
php server.php reload
php server.php reload -g

Workerman documentation: https://github.com/walkor/workerman-manual

You can also select a diferent cli php.ini directly:

php -c cli-php.ini server.php start

Help with session issues

I was using this lib internally, for more than 2 years, to run legacy apps with Workerman.

We made it for APIs and microservices. So the session is not well tested.

Login progress

It's working with Symfony and Laravel

Laravel Orchid admin panel. image

Drupal showing public pages. image