recca0120/laravel-parallel
155,427
63
Larablocks Analysis
recca0120/laravel-parallel works with any PHP project: the latest release (v1.4.1, May 3, 2024) doesn't depend on Laravel.
Recommendation checks
Not advisedNot advised: no release or commit in over 2 years.
- No release or commit in over 2 years
- No release in the last 12 months (last: May 3, 2024)
- 6,179 downloads a month (needs 10,000)
- 63 GitHub stars (needs 100)
State
Likely abandoned- No release or commit in over 2 years.
- Last stable release: May 3, 2024.
- No releases in the last 12 months.
- First released: Jun 11, 2021.
- Monthly downloads: 6,179, up 26% from six months ago.
- 1 open issue on GitHub.
Data from Packagist and GitHub, checked by Larablocks on Dec 2, 2026.
| Install | |
|---|---|
composer require recca0120/laravel-parallel |
|
| Latest Version: | v1.4.1 |
| License: | MIT |
| Last Updated: | May 3, 2024 |
| Links: | GitHub · Packagist |
Maintainer: recca0120
Laravel Parallel

Requirements
- Laravel versions 5.7, 6.x, 7.x, 8.x, 9.x, 10.x and 11.x
- PHP 7.0 or greater
Installation
Install the package with composer:
composer require recca0120/laravel-parallel
Usage
- make a product migration
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateProductsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('products', function (Blueprint $table) {
$table->id();
$table->string('name');
$table->integer('quantity')->default(0);
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('products');
}
}
- define product model
App\Models\Product
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
/**
* Class Product.
* @property int id
* @property string name
* @property int quantity
* @package App\Models
* @mixin Builder
*/
class Product extends Model
{
use HasFactory;
protected $fillable = ['name', 'quantity'];
protected $casts = ['quantity' => 'int'];
}
- define router in
routes/web.php
<?php
use App\Models\Product;
use Illuminate\Support\Facades\Route;
Route::get('/product/{productId}', function ($productId) {
return Product::findOrFail($productId);
});
Route::post('/product/{productId}', function ($productId) {
$product = Product::findOrFail($productId);
if ($product->quantity > 0) {
// wrong, it will make test fail
// $product->fill(['quantity' => $product->quantity - 1])->save();
// correct
$product->where('id', $product->id)
->where('quantity', '>', 0)
->update(['quantity' => DB::raw('quantity - 1')]);
}
return $product->fresh();
});
- testing
<?php
namespace Tests\Feature;
use App\Models\Product;
use Illuminate\Foundation\Testing\DatabaseMigrations;
use Recca0120\LaravelParallel\Tests\Concerns\WithParallelPhyiscalDatabase;
use Recca0120\LaravelParallel\Tests\ParallelRequest;
use Tests\TestCase;
class RaceConditionTest extends TestCase
{
use DatabaseMigrations;
use WithParallelPhyiscalDatabase;
private $product;
private $quantity = 10;
public function test_race_condition()
{
$this->useParallelPhyiscalDatabase();
$this->product = Product::create(['name' => 'test', 'quantity' => $this->quantity]);
$request = $this->app->make(ParallelRequest::class);
$promises = collect();
for ($i = 0; $i < $this->quantity; $i++) {
// you will get \GuzzleHttp\Promise\PromiseInterface
$promise = $request->post('/product/'.$this->product->id);
$promises->add($promise);
}
// you need wait response
$promises->map->wait()->each->assertOk();
$this->get('/product/'.$this->product->id)
->assertOk()
->assertJsonPath('quantity', 0);
}
public function test_multiple_times_to_test_race_condition()
{
$this->useParallelPhyiscalDatabase();
$this->product = Product::create(['name' => 'test', 'quantity' => $this->quantity]);
$request = $this->app->make(ParallelRequest::class);
$promises = collect($request->times(10)->post('/product/'.$this->product->id));
// you need wait response
$promises->map->wait()->each->assertOk();
$this->get('/product/'.$this->product->id)
->assertOk()
->assertJsonPath('quantity', 0);
}
}
License
The MIT License (MIT). Please see License File for more information.
Related Packages
greenlight/greenlight
A test framework for PHP 8.4+ with typed attributes, parallel execution, flat me...
5,476
23
kmuenkel/parallel-collection
A Laravel wrapper for amphp/amp offering a Collection Macro that performs parall...
4,327
2
igorsgm/illuminate-concurrency
Standalone extraction of Laravel's Illuminate Concurrency component. Run tasks c...
36
1
Version History
| Version | Released | License |
|---|---|---|
| v1.4.1 | MIT | |
| v1.4.0 | MIT | |
| v1.3.0 | MIT | |
| v1.2.0 | MIT | |
| v1.1.0 | MIT | |
| v1.0.2 | MIT | |
| v1.0.1 | MIT | |
| v1.0.0 | MIT | |
| v0.0.8 | MIT | |
| v0.0.7 | MIT | |
| v0.0.3 | MIT | |
| v0.0.2 | MIT | |
| v0.0.1 | MIT |