Download the PHP package ahmedanbar/devguard without Composer
On this page you can find all versions of the php package ahmedanbar/devguard. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download ahmedanbar/devguard
More information about ahmedanbar/devguard
Files in ahmedanbar/devguard
Package devguard
Short Description Developer CLI toolkit for Laravel projects — deploy readiness scoring and architecture enforcement.
License MIT
Informations about the package devguard
DevGuard
A modular CLI toolkit for Laravel projects. Audits production-readiness, clean architecture, env consistency, and dependency CVEs — in under 2 seconds.
📖 Full documentation: github.com/AhmedAnbar/devguard/wiki — installation, every command, every rule, CI recipes, troubleshooting.
Features
- Deploy Readiness Score — 7 production-readiness checks (env, debug, cache, queue, rate limit, https, logging) with a 0–100 score.
- Architecture Enforcer — 6 clean-architecture rules (folder structure, fat controllers, complexity, direct DB calls, service/repository layers).
- Env Audit —
.envvs.env.exampleconsistency, drift across.env.testing/.env.staging/etc., undeclaredenv()calls in code, weak APP_KEY. - Dependency Audit — wraps
composer auditto surface CVEs and abandoned packages from yourcomposer.lock. - Git hook installer —
devguard install-hookadds a pre-push (or pre-commit) gate so checks block bad commits before they ship. - Auto-fix —
devguard fix depsrunscomposer update <pkg>for each advisory;devguard fix envwrites missing keys from.env.example(with backup). - Baseline file +
@devguard-ignoreannotations —devguard baselinerecords existing issues so future runs only surface NEW ones. Adopt on legacy projects without fixing 200 things on day one. --changed-onlymode — scan only files ingit diffinstead of every PHP file. Pre-commit hooks become sub-second on big projects.- Interactive menu when run with no arguments.
- JSON output for CI/CD pipelines.
- HTML report —
--htmlwrites a self-contained, styled page (no CDN, no JS) you can email, archive as a CI artifact, or open locally. - SARIF output —
--sarifemits a SARIF 2.1.0 file. Upload viagithub/codeql-action/upload-sarifand DevGuard findings appear as inline annotations on PR diffs in GitHub Code Scanning. - Exit codes that fail builds when problems are found.
- Zero config — works out of the box; override per-project via
devguard.php.
Install
As a project dev dependency (recommended)
Globally
The OR-chain is required for 0.x packages — Composer's caret operator pins to the minor, not the major. (Why?)
Make sure ~/.composer/vendor/bin is on your PATH.
As a GitHub Action (CI-only — no Composer install needed)
Full setup, options, and Code Scanning integration: GitHub Actions in the wiki.
For other CI systems (GitLab CI, Bitbucket, Jenkins, CircleCI), see Other CI Systems.
Usage
GitHub Code Scanning (SARIF)
DevGuard findings then appear as inline annotations on PR diffs and in the repository's Security → Code scanning tab. Severities map: Status::Fail → error, Status::Warning → warning. Pass results aren't emitted. The partialFingerprints reuse the same signature scheme as the baseline file, so GitHub correctly tracks "same issue across runs" without re-flagging fixed items.
Adopting on a legacy codebase: baseline + ignores
Run once on a project that has 50 issues:
Now future devguard run invocations skip the baselined 50 and only surface what's new. To see everything anyway, pass --no-baseline. To regenerate after fixing a chunk, run devguard baseline again.
For one-off exceptions in code (no need to bake them into the baseline):
The annotation can sit on the same line or directly above the issue.
Auto-fix
| Tool | Fixable? | What devguard fix <tool> does |
|---|---|---|
deps |
✅ yes | composer update <pkg> --with-dependencies per advisory |
env |
✅ yes | Append missing keys from .env.example, backup to .env.devguard.bak |
deploy |
❌ not yet | Most issues need human judgement (which queue, which cache) |
architecture |
❌ no | Refactoring is human work — no safe auto-fix |
Default is interactive: every mutation prompts for y/N. --dry-run shows the plan without writing. --yes is for CI / when you trust the plan.
Exit codes
| Code | Meaning |
|---|---|
| 0 | All checks passed (warnings allowed) |
| 1 | At least one failed check |
| 2 | Tool error / unrecoverable failure |
CI pipelines can fail the build on non-zero exit.
Tools
Deploy Readiness Score
| Check | Default impact | What it looks for |
|---|---|---|
env_file_exists |
20 | .env present at project root |
debug_mode |
15 | APP_DEBUG is not true in production |
cache_configured |
10 | CACHE_STORE is a production driver |
queue_configured |
10 | QUEUE_CONNECTION isn't sync/null |
rate_limit |
10 | throttle middleware present on routes |
https_enforced |
10 | URL::forceScheme('https') or APP_URL |
logging_configured |
5 | LOG_CHANNEL isn't single/null |
Architecture Enforcer
| Rule | Severity | Detection |
|---|---|---|
folder_structure |
fail | Required Laravel directories exist |
fat_controller |
fail | Controller > 300 lines |
business_logic_in_controller |
fail/warn | Cyclomatic complexity > 10 / 6 |
direct_db_in_controller |
fail | DB::table/select/insert/... in actions |
service_layer |
warn | app/Services exists & non-empty |
repository_layer |
warn | app/Repositories exists & non-empty |
JSON output
Configuration
Drop a devguard.php at your project root to override defaults. Only the keys you specify are merged on top of the built-ins.
Extending — add your own tool
-
Create a class implementing
DevGuard\Contracts\ToolInterface: - Register it in
bin/devguard(or your own entry script):
That's it — the menu, tools list, JSON renderer, and exit-code logic all pick it up automatically.
Development
Tests run against fixtures under tests/Fixtures/ — a deliberately broken Laravel app and a clean one. CI runs both PHP 8.2 and 8.3.
License
MIT
All versions of devguard with dependencies
laravel/prompts Version ^0.1 || ^0.2 || ^0.3
nikic/php-parser Version ^5.0
symfony/console Version ^7.0
symfony/finder Version ^7.0
symfony/process Version ^7.0
vlucas/phpdotenv Version ^5.6