Download the PHP package laravel-parallel/laravel-parallel without Composer

On this page you can find all versions of the php package laravel-parallel/laravel-parallel. 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 laravel-parallel

Laravel Parallel

Simple parallel processing for Laravel - Powered by AMPHP with automatic CPU detection.

Latest Version Total Downloads License PHP Version


Laravel Parallel provides an intuitive, Laravel-style API for true parallel processing in your applications. Built on the battle-tested amphp/parallel library, it enables you to execute CPU-intensive tasks concurrently with automatic CPU core detection and comprehensive error handling.

Features

Installation

You can install the package via Composer:

Requirements

Laravel Version Package Version
11.x, 12.x ^2.0

Configuration (Optional)

Publish the configuration file:

This will create a config/parallel.php file where you can customize default settings.

Quick Start

Execute tasks in parallel with a simple, fluent API:

That's it! Laravel Parallel automatically detects your CPU cores and distributes work efficiently.

Usage Examples

Basic Parallel Execution

Execute multiple tasks concurrently:

Parallel Map Operation

Process collections in parallel:

Configuration

Customize worker count and timeout:

Real-World Example: Parallel API Requests

Fetch multiple API endpoints simultaneously:

Configuration

The package works out-of-the-box with sensible defaults. You can customize behavior via the config file or environment variables:

Config Key Env Variable Default Description
default_workers PARALLEL_WORKERS null (auto-detect) Number of worker processes
default_timeout PARALLEL_TIMEOUT 30 Timeout in seconds
max_workers PARALLEL_MAX_WORKERS 128 Maximum workers allowed
max_tasks_per_batch PARALLEL_MAX_TASKS 10000 Max tasks per batch
auto_chunk PARALLEL_AUTO_CHUNK true Auto-chunk large batches
chunk_size PARALLEL_CHUNK_SIZE 1000 Size of chunks
events.enabled PARALLEL_EVENTS_ENABLED true Enable task events
logging.enabled PARALLEL_LOGGING_ENABLED true Enable logging
logging.channel PARALLEL_LOG_CHANNEL stack Log channel
logging.level PARALLEL_LOG_LEVEL info Minimum log level

See the full configuration file for all options and detailed descriptions.

Advanced Usage

Working with Results

The result collection provides powerful methods for handling parallel execution outcomes:

Execution Metrics

Track performance with built-in metrics:

Error Handling

Handle failures gracefully:

Event Listeners

Listen to task lifecycle events:

Integrations

Laravel Parallel integrates seamlessly with popular Laravel ecosystem tools to enhance monitoring, observability, and developer experience.

Laravel Horizon Integration

Monitor your parallel tasks in real-time through Laravel Horizon's dashboard. The Horizon integration provides:

The integration is included with the package and activates automatically when Laravel Horizon is detected. Simply install Horizon and start using Laravel Parallel - metrics will appear in your Horizon dashboard immediately.

Quick Start:

For detailed setup instructions, API documentation, and advanced configuration options, see the Horizon Integration Guide.

Laravel Telescope Integration

Debug and profile your parallel tasks with Laravel Telescope's powerful inspection tools. The Telescope integration provides:

The integration is included with the package and activates automatically when Laravel Telescope is detected. Task details appear in a dedicated "Parallel Task" section within your Telescope dashboard.

Quick Start:

For detailed setup instructions, configuration options, and debugging workflows, see the Telescope Integration Guide.

Future Integrations

Planned integrations for upcoming releases:

Extending the Package

Laravel Parallel is built with extensibility in mind. You can create:

Creating a Custom Task

Best Practices

  1. Keep Tasks Self-Contained: Tasks should contain all data needed for execution
  2. Handle Serialization: Ensure all task data is serializable
  3. Resource Management: Recreate database connections and resources in worker processes
  4. Error Handling: Always handle exceptions and return meaningful error information

Architecture

Laravel Parallel follows Hexagonal Architecture (Ports & Adapters) and SOLID principles for maximum maintainability and extensibility.

Key Components

The package wraps the powerful amphp/parallel library with a Laravel-friendly interface.

Design Patterns

Testing

Run the test suite:

Run tests with coverage:

Run static analysis:

The package maintains:

Performance

When to Use Laravel Parallel

Ideal For:

Better Alternatives:

Overhead Analysis

Example Performance

Performance Tips

1. Optimal Worker Count

2. Chunk Large Datasets

3. Balance Task Size

Frequently Asked Questions

Can I use this with Laravel Octane/Swoole?

Yes! Laravel Parallel v2.0+ is fully compatible with Laravel Octane and Swoole. The package uses non-singleton bindings to prevent state leakage between requests.

How is this different from Laravel Queues?

Laravel Queues are designed for background processing with delayed execution, while Laravel Parallel is for immediate parallel execution:

Use queues for background jobs, use parallel processing for immediate CPU-intensive operations.

How many workers should I use?

The optimal number depends on your task type:

What happens if a task throws an exception?

Exceptions are caught and wrapped in a ParallelResult with isFailure() === true. Other tasks continue executing independently. You can handle failures gracefully:

Can I use database connections in parallel tasks?

Yes, but you need to be aware that each worker process has its own memory space. Database connections should be recreated within each task:

How do I retry failed tasks?

Extract failed task keys and rerun them:

Is this package production-ready?

Yes! Laravel Parallel v2.0+ is built with production in mind:

Changelog

Please see CHANGELOG for recent changes and version history.

Contributing

Contributions are welcome! Please see CONTRIBUTING for details.

Security Vulnerabilities

If you discover a security vulnerability, please email [email protected]. All security vulnerabilities will be promptly addressed.

Credits

License

The MIT License (MIT). Please see License File for more information.


All versions of laravel-parallel with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
illuminate/support Version ^11.0|^12.0
illuminate/contracts Version ^11.0|^12.0
amphp/parallel Version ^2.3
laravel/serializable-closure Version ^2.0
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 laravel-parallel/laravel-parallel contains the following files

Loading the files please wait ...