Skip to content

Commit e619639

Browse files
committed
init
0 parents  commit e619639

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+3963
-0
lines changed

.github/workflows/ci.yml

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [ main, develop ]
6+
pull_request:
7+
branches: [ main, develop ]
8+
9+
jobs:
10+
test:
11+
name: PHP ${{ matrix.php-version }} - ${{ matrix.os }}
12+
runs-on: ${{ matrix.os }}
13+
14+
strategy:
15+
fail-fast: false
16+
matrix:
17+
os: [ubuntu-latest, windows-latest, macos-latest]
18+
php-version: ['8.0', '8.1', '8.2']
19+
20+
steps:
21+
- uses: actions/checkout@v4
22+
23+
- name: Setup PHP
24+
uses: shivammathur/setup-php@v2
25+
with:
26+
php-version: ${{ matrix.php-version }}
27+
extensions: json
28+
coverage: xdebug
29+
tools: composer:v2
30+
31+
- name: Validate composer.json
32+
run: composer validate --strict
33+
34+
- name: Cache Composer packages
35+
id: composer-cache
36+
uses: actions/cache@v3
37+
with:
38+
path: vendor
39+
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
40+
restore-keys: |
41+
${{ runner.os }}-php-
42+
43+
- name: Install dependencies
44+
run: composer install --prefer-dist --no-progress
45+
46+
- name: Run test suite
47+
run: vendor/bin/phpunit --coverage-text
48+
49+
- name: Verify binary installation
50+
run: |
51+
php -r "require 'vendor/autoload.php'; new VoltTest\Platform();"
52+
53+
static-analysis:
54+
name: Static Analysis
55+
runs-on: ubuntu-latest
56+
57+
steps:
58+
- uses: actions/checkout@v4
59+
60+
- name: Setup PHP
61+
uses: shivammathur/setup-php@v2
62+
with:
63+
php-version: '8.2'
64+
tools: composer:v2, phpstan
65+
66+
- name: Install dependencies
67+
run: composer install --prefer-dist --no-progress
68+
69+
- name: Run PHPStan
70+
run: phpstan analyse src tests --level=5
71+
72+
code-style:
73+
name: Code Style
74+
runs-on: ubuntu-latest
75+
76+
steps:
77+
- uses: actions/checkout@v4
78+
79+
- name: Setup PHP
80+
uses: shivammathur/setup-php@v2
81+
with:
82+
php-version: '8.2'
83+
tools: composer:v2, php-cs-fixer
84+
85+
- name: Check coding standards
86+
run: php-cs-fixer fix --dry-run --diff
87+
88+
security-check:
89+
name: Security Check
90+
runs-on: ubuntu-latest
91+
92+
steps:
93+
- uses: actions/checkout@v4
94+
95+
- name: Setup PHP
96+
uses: shivammathur/setup-php@v2
97+
with:
98+
php-version: '8.2'
99+
tools: composer:v2
100+
101+
- name: Install dependencies
102+
run: composer install --prefer-dist --no-progress
103+
104+
- name: Security check
105+
uses: symfonycorp/security-checker-action@v4

.gitignore

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#php
2+
/vendor/
3+
composer.phar
4+
composer.lock
5+
6+
# PHPUnit
7+
.phpunit.result.cache
8+
.phpunit.cache
9+
coverage/
10+
.phpunit.cache/
11+
.php-cs-fixer.cache
12+
.phpstan.result.cache
13+
14+
# IDE
15+
.idea/
16+
.vscode/
17+
*.sublime-project
18+
*.sublime-workspace
19+
*.swp
20+
*.swo
21+
22+
# OS generated files
23+
.DS_Store
24+
.DS_Store?
25+
._*
26+
.Spotlight-V100
27+
.Trashes
28+
ehthumbs.db
29+
Thumbs.db
30+
31+
# Project specific
32+
/tmp/
33+
*.log
34+
*.cache
35+
.env
36+
.env.local
37+
.env.*.local
38+
TODO.md

.php-cs-fixer.dist.php

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<?php
2+
3+
$finder = PhpCsFixer\Finder::create()
4+
->in([
5+
__DIR__ . '/src',
6+
__DIR__ . '/tests',
7+
])
8+
->exclude('vendor')
9+
->name('*.php')
10+
->ignoreDotFiles(true)
11+
->ignoreVCS(true);
12+
13+
$config = new PhpCsFixer\Config();
14+
15+
return $config
16+
->setRules([
17+
'@PSR12' => true,
18+
'array_syntax' => ['syntax' => 'short'],
19+
'ordered_imports' => ['sort_algorithm' => 'alpha'],
20+
'no_unused_imports' => true,
21+
'not_operator_with_successor_space' => true,
22+
'trailing_comma_in_multiline' => true,
23+
'phpdoc_scalar' => true,
24+
'unary_operator_spaces' => true,
25+
'binary_operator_spaces' => true,
26+
'blank_line_before_statement' => [
27+
'statements' => ['break', 'continue', 'declare', 'return', 'throw', 'try'],
28+
],
29+
'phpdoc_single_line_var_spacing' => true,
30+
'phpdoc_var_without_name' => true,
31+
'class_attributes_separation' => [
32+
'elements' => [
33+
'method' => 'one',
34+
'property' => 'one',
35+
],
36+
],
37+
'method_argument_space' => [
38+
'on_multiline' => 'ensure_fully_multiline',
39+
'keep_multiple_spaces_after_comma' => true,
40+
],
41+
'single_trait_insert_per_statement' => true,
42+
])
43+
->setFinder($finder);

Examples/.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
!.gitignore
2+
*.php
3+
*.csv

LICENSE.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2025 VoltTest PHP SDK
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
# VoltTest PHP SDK
2+
3+
VoltTest is a powerful, easy-to-use performance testing SDK for PHP applications.
4+
Powered by a high-performance Golang engine running behind the scenes,
5+
it combines the ease of use of PHP with the raw power and concurrency capabilities of Go.
6+
This unique architecture enables you to create, run, and analyze performance tests with a fluent,
7+
intuitive API while leveraging Go's superior performance characteristics for the actual load generation.
8+
9+
## Architecture
10+
VoltTest PHP SDK works as a bridge between your PHP application and the VoltTest Engine (written in Go). When you run a test:
11+
12+
Your PHP code defines the test scenarios and configurations
13+
The SDK transforms these into a format the Go engine understands
14+
The Go engine executes the actual load testing
15+
Results are streamed back to your PHP application for analysis
16+
17+
This architecture provides several benefits:
18+
19+
Write tests in PHP while getting Go's performance benefits
20+
True parallel execution of virtual users
21+
Minimal resource footprint during test execution
22+
Accurate timing and metrics collection
23+
24+
## Documentation
25+
26+
For detailed documentation, visit [https://php.volt-test.com](https://php.volt-test.com)
27+
28+
## Quick Start
29+
30+
### Installation
31+
32+
```bash
33+
composer require volt-test/php-sdk
34+
```
35+
36+
### Basic Usage
37+
38+
```php
39+
use VoltTest\VoltTest;
40+
41+
// Create a new test
42+
$test = new VoltTest('API Load Test', 'Testing API endpoints under load');
43+
44+
// Configure the test
45+
$test->setVirtualUsers(10)
46+
->setDuration('1m')
47+
->setRampUp('10s')
48+
->setTarget('https://api.example.com');
49+
50+
// Create a test scenario
51+
$scenario = $test->scenario('Basic API Flow')
52+
->setWeight(1)
53+
->autoHandleCookies();
54+
55+
// Add test steps
56+
$scenario->step('Get Users')
57+
->get('/api/users')
58+
->validateStatus('success', 200)
59+
->extractFromJson('userId', 'data[0].id');
60+
61+
$scenario->step('Get User Details')
62+
->get('/api/users/${userId}')
63+
->validateStatus('success', 200);
64+
65+
// Run the test
66+
$result = $test->run();
67+
68+
// Access test results
69+
echo "Success Rate: " . $result->getSuccessRate() . "%\n";
70+
echo "Average Response Time: " . $result->getAvgResponseTime() . "\n";
71+
```
72+
73+
## Features
74+
75+
- Cross-platform support (Windows, Linux, MacOS)
76+
- Data Provider for Virtual Users
77+
- Comprehensive performance metrics
78+
- Multiple scenario support with weights
79+
- Request customization
80+
- Response validation
81+
- Think time simulation
82+
- Ramp-up configuration
83+
- Progress tracking
84+
- Detailed reports
85+
- Debug Requests
86+
- Easy-to-use API
87+
88+
## Requirements
89+
90+
- PHP 8.0 or higher
91+
- ext-json
92+
- ext-pcntl
93+
94+
## License
95+
96+
The MIT License (MIT). Please see [License File](LICENSE.md) for more information.
97+
98+
For more examples and detailed documentation, visit [https://php.volt-test.com](https://php.volt-test.com)
8.02 MB
Binary file not shown.
8.03 MB
Binary file not shown.
8.24 MB
Binary file not shown.

composer.json

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
{
2+
"name": "volt-test/php-sdk",
3+
"description": "Volt Test PHP SDK - A performance testing tool for PHP applications",
4+
"type": "library",
5+
"keywords": [
6+
"volt-test",
7+
"php-sdk",
8+
"performance-testing",
9+
"load-testing",
10+
"stress-testing",
11+
"http"
12+
],
13+
"homepage": "https://php.volt-test.com",
14+
"license": "MIT",
15+
"support": {
16+
"issues": "https://github.com/volt-test/php-sdk/issues",
17+
"source": "https://github.com/volt-test/php-sdk/"
18+
},
19+
"version": "0.0.1",
20+
"authors": [
21+
{
22+
"name": "elwafa",
23+
"email": "[email protected]"
24+
}
25+
],
26+
"require": {
27+
"php": "^8.0",
28+
"ext-json": "*",
29+
"ext-pcntl": "*"
30+
},
31+
"autoload": {
32+
"psr-4": {
33+
"VoltTest\\": "src/"
34+
}
35+
},
36+
"autoload-dev": {
37+
"psr-4": {
38+
"Tests\\": "tests/"
39+
}
40+
},
41+
"scripts": {
42+
"post-install-cmd": [
43+
"VoltTest\\Platform::installBinary"
44+
],
45+
"post-update-cmd": [
46+
"VoltTest\\Platform::installBinary"
47+
],
48+
"volt-test": [
49+
"VoltTest\\Platform::installBinary"
50+
],
51+
"test": "phpunit",
52+
"cs": "PHP_CS_FIXER_IGNORE_ENV=1 php-cs-fixer fix --diff",
53+
"cs-check": "PHP_CS_FIXER_IGNORE_ENV=1 php-cs-fixer fix --dry-run --diff",
54+
"analyze": "phpstan analyze",
55+
"check": [
56+
"@cs-check",
57+
"@analyze",
58+
"@test"
59+
]
60+
},
61+
"config": {
62+
"bin-dir": "vendor/bin"
63+
},
64+
"require-dev": {
65+
"phpunit/phpunit": "^11.5",
66+
"phpstan/phpstan": "^1.10",
67+
"friendsofphp/php-cs-fixer": "^3.51"
68+
}
69+
}

0 commit comments

Comments
 (0)