styleci/sdk
Official PHP SDK for StyleCI: authenticate and interact with the API to manage repositories, fetch analyses, view fix results, and trigger or monitor code style checks from your Laravel or PHP applications.
styleci/sdk is a PHP SDK for interacting with StyleCI, a code standards fixer and formatter service. It is well-suited for Laravel applications where:
php artisan styleci:fix).scheduler:run) align well with SDK usage (e.g., wrapping API calls in a service class).git:commit or deploy events to auto-format.spatie/laravel-activitylog for audit trails (if tracking fixes)./api/v1/checker (status checks)/api/v1/fixer (trigger fixes)config or env (e.g., STYLECI_TOKEN).styleci:check, styleci:fix).released or git:commit events.styleci CLI usage (replace with SDK).// app/Providers/AppServiceProvider.php
public function register()
{
$this->app->singleton(StyleCI::class, function () {
return new \StyleCI\SDK\StyleCI(config('services.styleci.token'));
});
}
// app/Console/Commands/StyleCIFix.php
public function handle()
{
$styleci = app(StyleCI::class);
$result = $styleci->fixer()->fix();
$this->info($result->message());
}
.github/workflows/php.yml:
- name: Run StyleCI
run: php artisan styleci:fix
$client = new \GuzzleHttp\Client();
$response = $client->post('https://styleci.io/api/v1/fixer', [
'auth' => [config('services.styleci.token'), ''],
'json' => ['github_token' => config('services.github.token')],
]);
styleci CLI calls with SDK.try-catch for API calls").php artisan styleci:help).styleci:fix in background).styleci:check results) for 5 mins.| Failure | Impact | Mitigation |
|---|---|---|
| SDK API incompatibility | Breaks formatting workflows | Fallback to Guzzle + direct API calls |
| Rate limiting | CI/CD pipeline failures | Implement retries + caching |
| Token leakage | Security risk | Use Laravel’s env + .gitignore |
| StyleCI service outage | No code formatting | Add CLI fallback (e.g., php-cs-fixer) |
styleci:fix intuitive?").How can I help you explore Laravel packages today?