Download the PHP package byjg/phpthread without Composer

On this page you can find all versions of the php package byjg/phpthread. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package phpthread


sidebar_key: phpthread tags: [php, concurrency]

ByJG PHPThread: Simplified Threads and Non-Blocking Code in PHP

ByJG PHPThread simplifies working with threads and non-blocking code in PHP, bridging the gap for a language that was not inherently designed for threading.

Sponsor Build Status Opensource ByJG GitHub source GitHub license GitHub release


Table of Contents

  1. Overview
  2. Why Threads in PHP?
  3. How It Works
    • Default PHP (Non-ZTS)
    • PHP ZTS (Zend Thread Safety)
  4. Features
  5. Limitations
  6. Installation
  7. Dependencies

Overview

PHPThread is a polyfill library that abstracts threading functionality for PHP, providing a consistent interface regardless of the underlying PHP setup (ZTS or Fork). It empowers developers to implement thread-like behavior and asynchronous processing in PHP applications.


Why Threads in PHP?

PHP is traditionally designed for a request-response cycle, where scripts are executed only in response to client requests and terminate after sending a response. While efficient for web applications, this architecture lacks native threading support for background or concurrent tasks.

With PHPThread, you can overcome these limitations by leveraging:


How It Works

Default PHP (Non-ZTS)

In standard PHP installations (without ZTS), threading is simulated using the fork command. This approach creates a new process by cloning the parent process. While not a true thread, this method can approximate threading behavior.

Requirements:


PHP ZTS (Zend Thread Safety)

With ZTS-enabled PHP, true multi-threading becomes possible. This setup is ideal for production environments where robust threading is required. The ZTS version is compiled with the --enable-zts flag, but it may not be included in all PHP distributions.

Requirements:


Features

Supported Promise Methods:


Limitations

CLI Mode Only

:::caution Important This library only works in CLI mode (command-line interface). It will NOT work in web server environments such as:

Why?

Both threading approaches used by this library require direct process control, which is unavailable in web server environments:

Additionally, forking or creating threads within a web server process would interfere with the server's own process/thread management, potentially causing instability.

Use Cases:

This library is designed for:

For web applications requiring asynchronous processing, consider using message queues (RabbitMQ, Redis, etc.) with background workers running in CLI mode.

Forking and Data Sharing

When simulating threads with fork, data cannot be returned directly from the child process to the parent. Use the shmop extension to share memory between processes.

However:


Installation

Requirements

Non-ZTS (Default PHP)

ZTS (Zend Thread Safety)

Install via Composer


Dependencies


Open source ByJG


All versions of phpthread with dependencies

PHP Build Version
Package Version
Requires byjg/cache-engine Version ^6.0
ext-pcntl Version *
ext-posix Version *
php Version >=8.3 <8.6
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package byjg/phpthread contains the following files

Loading the files please wait ...