{"id":21571163,"url":"https://github.com/cheprasov/php-parallel","last_synced_at":"2025-06-15T15:07:09.479Z","repository":{"id":58479137,"uuid":"50624122","full_name":"cheprasov/php-parallel","owner":"cheprasov","description":"The class allows you to run multiple operations parallel in different processes and send results to the main process. Useful if you need to run multiple independent operations simultaneously, instead of sequential execution, or if you run several independent queries, for example, queries to different data bases.","archived":false,"fork":false,"pushed_at":"2021-06-10T19:37:27.000Z","size":30,"stargazers_count":17,"open_issues_count":0,"forks_count":7,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-04-27T00:01:15.696Z","etag":null,"topics":["parallel","php"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cheprasov.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"github":"cheprasov","patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"custom":null}},"created_at":"2016-01-29T00:13:34.000Z","updated_at":"2023-10-15T14:40:33.000Z","dependencies_parsed_at":"2022-09-03T10:21:25.619Z","dependency_job_id":null,"html_url":"https://github.com/cheprasov/php-parallel","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cheprasov%2Fphp-parallel","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cheprasov%2Fphp-parallel/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cheprasov%2Fphp-parallel/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cheprasov%2Fphp-parallel/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cheprasov","download_url":"https://codeload.github.com/cheprasov/php-parallel/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248233935,"owners_count":21069493,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["parallel","php"],"created_at":"2024-11-24T11:15:06.292Z","updated_at":"2025-04-10T14:20:33.582Z","avatar_url":"https://github.com/cheprasov.png","language":"PHP","funding_links":["https://github.com/sponsors/cheprasov"],"categories":[],"sub_categories":[],"readme":"# Parallel v1.2.0 for PHP \u003e= 5.5\n\nThe class allows you to run multiple operations parallel in different thread and send results to the main process. Useful if you need to run multiple independent operations simultaneously, instead of sequential execution, or if you run several independent queries, for example, queries to different data bases.\n\n## Communications\n\nCommunications of data between processes is via one (or more) of storages:\n\n- APCu\n- Memcached\n- Redis\n\n## Using\n\n```php\n\u003c?php\n\nrequire (dirname(__DIR__).'/vendor/autoload.php');\n\nuse Parallel\\Parallel;\nuse Parallel\\Storage\\ApcuStorage;\n\n// EXAMPLE, how to run parallel 3 operations.\n\n// Using Parallel via ApcuStorage (APCu, see http://php.net/manual/ru/book.apcu.php)\n$Parallel = new Parallel(new ApcuStorage());\n\n// if you have not APCu, you can use Memcached or Redis as Storage.\n// Note: you can't store objects in Memcached or Redis and you can't store binary strings (use \u003cbase64\u003e functions)\n\n//    $Parallel = new Parallel(new \\Parallel\\Storage\\MemcachedStorage([\n//        'servers' =\u003e [['127.0.0.1', 11211]]\n//    ]));\n\n//    $Parallel = new Parallel(new \\Parallel\\Storage\\RedisStorage([\n//        'server' =\u003e 'tcp://127.0.0.1:6379'\n//    ]));\n\n$time = microtime(true);\n\n// 1st operation\n$Parallel-\u003erun('foo', function() {\n    // You can use Parallel inside run function by creating new objects Parallel.\n    // Example: $Parallel = new Parallel(new \\Parallel\\Storage\\ApcuStorage());\n    sleep(2);\n    return ['hello' =\u003e 'world'];\n});\n\n// 2nd operation\n$Parallel-\u003erun('obj', function() {\n    sleep(2);\n    return (object) ['a' =\u003e 1, 'b' =\u003e 2, 'c' =\u003e 3];\n});\n\n// 3th operation\n// do some thing ...\nsleep(2);\n\n// waiting for \u003cfoo\u003e and \u003cobj\u003e and get results.\n// use wait() without parameters for wait all forks. Example: $Parallel-\u003ewait();\n$result = $Parallel-\u003ewait(['foo', 'obj']);\n\nprint_r($result);\nprint_r(microtime(true) - $time);\n// 3 parallel operations by 2 seconds take about 2 seconds, instead 6 seconds.\n\n//    Array\n//    (\n//        [foo] =\u003e Array\n//            (\n//                [hello] =\u003e world\n//            )\n//\n//        [obj] =\u003e stdClass Object\n//            (\n//                [a] =\u003e 1\n//                [b] =\u003e 2\n//                [c] =\u003e 3\n//            )\n//    )\n//    2.0130307674408\n```\n\n## Installation\n\n### Composer\n\nDownload composer:\n\n    wget -nc http://getcomposer.org/composer.phar\n\nand add dependency to your project:\n\n    php composer.phar require cheprasov/php-parallel\n\n\n## Running tests\n\nTo run tests type in console:\n\n    ./vendor/bin/phpunit\n\n\n## Something doesn't work\n\nFeel free to fork project, fix bugs and finally request for pull\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcheprasov%2Fphp-parallel","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcheprasov%2Fphp-parallel","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcheprasov%2Fphp-parallel/lists"}