meandor / stirling-mysql
A MySQL wrapper for the sterling-microservice
Requires
- php: >=8.4
- ext-mysqli: >=8.4
- meandor/stirling-microservice: *
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.95
- infection/infection: ^0.35.8
- phpmd/phpmd: ^3.0
- phpstan/phpstan: ^2.3
- phpunit/phpunit: ^13
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
A MySQL Database wrapper for the stirling-microservice
This library uses mysqli for database access. Please make sure you have mysqli enabled and ready to work on your server.
Tools
The main script to do everything is
./bin/go
To see a list of arguments:
./bin/go help
To execute all tests:
./bin/go test
To scan the code and its dependencies for vulnerabilities, secrets and misconfigurations with Trivy (runs inside Docker, no binary to install — the image is pulled automatically on first run):
./bin/go security-check
This scans composer.lock (including dev dependencies) for known
vulnerabilities. It is a dependency scan, not a scan of your PHP source
code.
To check the code style with PHP CS Fixer (validates, does not change files):
./bin/go lint-check
To auto-fix the code style with PHP CS Fixer:
./bin/go lint
To statically analyse the code with PHPStan (level 4, checks src/):
./bin/go static-analysis
To check that no method exceeds the configured cyclomatic complexity threshold (uses PHPMD):
./bin/go complexity
To run lint-check, static-analysis, mutation-check, security-check, the complexity check and the tests all at once:
./bin/go check
The tests and mutation-check need a MySQL server. The defaults are
127.0.0.1:3306, user root, an empty password and the database test.
Usage
This library only works in conjunction with the stirling-microservice.
If you don't specify a config json (default.json) for your Config class with the following lines
{
"dbHost": "<ip address>",
"dbUser": "<my username>",
"dbPassword": "<my password>",
"dbName": "<my database name>",
"dbPort": <port>
}
a default config will be used to try to establish a database connection.
The default is:
{
"dbHost": "127.0.0.1",
"dbUser": "root",
"dbPassword": "",
"dbName": "database",
"dbPort": 3306
}