PHP SDK for Nginx Unit
About
SDK allows developers to interact with the Nginx Unit web server through php classes. This project will help embed web server management into your projects
Supported Versions
Version | Nginx Unit Capability | Supported |
---|---|---|
0.6.x | 1.30.0 & 1.31.0 | ✅ |
< 0.4.x | 1.30.0 | ❌ |
THIS PROJECT IN DEVELOPMENT. DON'T USE IT IN PRODUCTION
Quick start
Pre-requirements
- PHP >= 8.2
- PHP curl extension
- Composer >= 2
- Nginx unit >= 1.30.0
Installation
- Create folder
mkdir example-php-project
- Open folder
cd example-php-project
- Crate composer.json file. Example below:
{
"name": "user/example-php-project",
"require": {
"pavlusha311245/unit-php-sdk": "^0.6.0"
},
"autoload": {
"psr-4": {
"User\\ExamplePhpProject\\": "src/"
}
}
}
- Install packages
composer install
Congratulations! You installed package. Now you can use the full power of this SDK.
- Create
src/index.php
filecd src
(mkdir src
if folder doesn't exist)touch src/index.php
nano src/index.php
- Paste code and change this line
socket: <your socket path to Nginx Unit>
for your configuration
<?php
use UnitPhpSdk\Unit;
require '../vendor/autoload.php';
$unit = new Unit(
socket: <your socket path to Nginx Unit>,
address: 'http://localhost'
);
$unit->getConfig();
- Run
php index.php
Documentation
More examples and detailed information can be found in the documentation
Happy coding 😊
Changelog
More information about changes you can see here
Contribution
More info about contribution you can read here
Security Policy
If you find bugs and vulnerabilities, please contact unit@pavlusha.me.
More info here