A PHP 8.1+ CLI + API for compressing, resizing, and analyzing PDFs with Ghostscript, plus a gated web dashboard for Tech & Stream workflows.
- CLI:
bin/pdf_fitprovides smart, compress, optimize, extreme, resize, batch, and server modes. - API:
public/index.phpexposes a JSON API for PDF processing. - Dashboard: password-protected UI with the Tech & Stream “Agent Freelance” cockpit.
- Plugins: metadata extraction and thumbnail generation hooks.
- PHP 8.1+
- Composer
- Ghostscript (
gs) for compression/thumbnail generation - Optional: Poppler
pdfinfofor metadata enrichment
composer install
chmod +x bin/pdf_fit bin/job_applyphp bin/pdf_fit smart tests/Fixtures/example.pdf
php bin/pdf_fit compress report.pdf --quality=55 --dpi=150
php bin/pdf_fit resize brochure.pdf --width=1080 --height=1920
php bin/pdf_fit batch ./statements --mode=smart
php bin/pdf_fit server --host=0.0.0.0 --port=8080 --docroot=publicphp bin/job_apply docs/job_post.txt
php bin/job_apply docs/job_post.txt --jsonphp bin/project_velocity --blueprint=docs/blueprint.txt --sprint=1 --output=docs/sprint_1.mdphp -S 127.0.0.1:8080 -t public
# POST multipart/form-data:
# - pdf: file upload
# - mode: smart|compress|optimize|extreme|resize
# - quality/dpi/width/height: optional overridesExample:
curl -F pdf=@tests/Fixtures/example.pdf -F mode=smart http://127.0.0.1:8080Use config.php for persistent config or environment variables for quick overrides. Copy .env.example as needed.
| Setting | Description |
|---|---|
PDF_FIT_OUTPUT_SUFFIX |
Suffix appended to exported PDFs |
PDF_FIT_THUMBNAIL_QUALITY |
JPEG quality for thumbnail plugin |
PDF_FIT_LOG_FORMAT |
text or json |
PDF_FIT_DEBUG |
1 to include stack traces in CLI errors |
PDF_FIT_DASHBOARD_PASSWORD |
Required for dashboard access |
- Ghostscript not found: install
gsand ensure it is on PATH. The CLI warns and returns the original file if missing. - No PDFs in batch: batch mode exits with a warning if the directory has no
.pdffiles. - Dashboard locked: set
PDF_FIT_DASHBOARD_PASSWORDorconfig/security.local.php.
- The dashboard must be protected via
PDF_FIT_DASHBOARD_PASSWORDbefore deployment. - Do not expose
public/without a password gate in production environments.
bin/
pdf_fit
job_apply
config/
public/
src/
Api/
Batch/
Cli/
Core/
JobAgent/
Plugins/
Security/
Support/
AgentFreelance.php
- Fork and create a feature branch.
- Install dependencies:
composer install. - Run checks:
composer lintcomposer test
- Open a PR with a clear summary and screenshots when UI changes apply.
GitHub Actions runs lint + tests + build on every PR.
PR1 (README): update README with scope, setup, run, config, troubleshooting, security, and contribution workflow.
PR2 (Reliability):
- remove duplicate/dead classes
- centralize config validation
- structured logging + error handling
- add lint/type checks + CI updates
- add tests for config validation + CLI help paths
PR3 (UX/DX):
- improve CLI error messages
- add
--helpand readable usage output - better batch empty-state handling
- Remove duplicate root-level
src/Pipeline.php+ related legacy classes; keepsrc/Core/*versions. - Introduce
src/Core/Config.phpto validate config + env overrides. - Fix
src/Cli/ArgvParser.phpto support--helpand consistent option parsing. - Update
.github/workflows/ci.ymlto run lint, phpstan, and tests.