scrutinizer/ocular
Ocular is a PHP client for Scrutinizer CI that fetches and submits code coverage data, making it easy to report test coverage from your build pipeline to Scrutinizer. Useful for integrating PHP test suites and coverage tools with Scrutinizer projects.
Download the ocular.phar file from https://scrutinizer-ci.com/ocular.phar (recommended for stability and simplicity), or install via composer require --dev scrutinizer/ocular. Your first step is to generate a coverage report—e.g., run PHPUnit with --coverage-clover=coverage.xml in your CI or local environment—then upload it with ocular.phar phar:upload coverage.xml. Ensure the SCRUTINIZER_TOKEN environment variable is set (via CI secrets or local .env) with a valid token from your Scrutinizer CI project; without it, uploads fail with a clear 401 error.
.github/workflows/ci.yml or GitLab CI, add a post-test step: curl -sS https://scrutinizer-ci.com/ocular.phar -o ocular.phar && php ocular.phar phar:upload build/logs/clover.xml. This keeps tooling self-contained and avoids installing extra dependencies.nyc report --reporter clover for JavaScript, or gcovr --cobertura for C++) to produce Clover/CSV format, then pipe directly to ocular. Ideal for Laravel monorepos where backend (PHP) and frontend (JS/TS) coverage must appear in Scrutinizer’s unified dashboard.php ocular.phar phar:upload coverage.xml --dry-run -v—this verifies authentication, repository metadata, and file validity without consuming API quota.curl -L -o ocular.phar https://scrutinizer-ci.com/ocular.phar?version=1.8.1) to eliminate runtime variability.fetch-depth: 1 (e.g., GitHub Actions) may fail with cryptic Git errors. Upgrade to ocular ≥1.8.1 (or use the latest PHAR) for graceful fallback—older versions lack clear diagnostics.C:\path\to\file.xml). Avoid by using the PHAR (bundled with paths normalized) or upgrading if using Composer.SCRUTINIZER_TOKEN must be project-specific (found in Scrutinizer’s “Settings > CI/CD > API Token”). A global account token fails silently; always validate with --dry-run.jms/serializer:^3.0 may clash with Laravel’s symfony/serializer (used in ORM/OXM). Prefer PHAR over Composer unless you lock all versions (composer require --lock).-vvv for full Guzzle debug output—this reveals HTTP status codes (e.g., 422 = malformed report, 404 = invalid repo/branch). Inspect coverage.xml’s <directory> attributes; Scrutinizer expects absolute paths (use --coverage-clover=coverage.xml --force in PHPUnit to ensure path normalization).codecov CLI for broader support and active development.How can I help you explore Laravel packages today?