phar-io/gnupg
PHP wrapper for GnuPG used by phar-io tools, providing a simple API to verify and manage PGP signatures in PHP. Helps integrate GPG key handling and signature checks into builds and distribution workflows.
phar-io/gnupg package provides a PHP wrapper for the gnupg binary, enabling encryption/decryption, key management, and signing operations—critical for security-sensitive applications (e.g., PGP-compliant email, secure file storage, or compliance-driven workflows).Illuminate\Encryption) is limited to symmetric algorithms (AES). This package extends Laravel’s capabilities to asymmetric encryption (RSA/ElGamal) and digital signatures, aligning with use cases requiring non-repudiation or multi-party key exchange.pecl/gnupg API, reducing learning curve for teams familiar with PHP’s native GnuPG bindings. However, its thin wrapper design may expose low-level complexity (e.g., binary dependency management, error handling) to the application layer.gnupg binary (Linux: apt-get install gnupg; macOS: brew install gnupg; Windows: manual install via Gpg4win).GnuPG::encrypt(), GnuPG::decrypt()).$this->app->singleton('gnupg', function ($app) {
return new \PharIo\GnuPG\GnuPG();
});
~/.gnupg) but lacks built-in Laravel config integration. Would need custom config files or environment variables for key paths.gnupg in their base layer.GnuPGException) may not align with Laravel’s exception handling (e.g., Handler middleware). Custom exception mapping may be needed.config/cache or filesystem disks. Custom logic required for key storage/retrieval.openssl_* functions or libraries like paragonie/halite suffice for symmetric use cases?gnupg binary be versioned and updated across environments (dev/staging/prod)?gnupg) feasible?config or a dedicated key management system (e.g., HashiCorp Vault)?gnupg binary is unavailable? Should the app degrade gracefully or fail fast?gnupg binary may complicate multi-language stacks (e.g., Go/Python services).paragonie/halite: Pure PHP (no binary), but limited to symmetric encryption.web-token/jwt + RSA: For JWT signing, but lacks full PGP compatibility.gnupg: More features (e.g., gpg --clearsign), but harder to install/maintain.phar-io/gnupg in a Laravel test project.encrypt() for performance.// app/Providers/GnuPGServiceProvider.php
public function register() {
$this->app->singleton('gnupg', function () {
$gnupg = new \PharIo\GnuPG\GnuPG();
$gnupg->setHomedir(storage_path('gnupg'));
return $gnupg;
});
}
config/app.php or a new gnupg.php file for homedir, key paths, etc.GnuPG facade or helper class to abstract binary operations.gnupg binary in Docker (e.g., FROM alpine:latest RUN apk add gnupg).gnupg --version).| Step | Task | Dependencies | Owner |
|---|---|---|---|
| 1 | Install phar-io/gnupg |
Composer | Dev |
| 2 | Set up gnupg binary in dev/prod |
System/Docker | Ops |
| 3 | Create Laravel service provider | Composer autoload | TPM |
| 4 | Implement key management (generate/retrieve keys) | Storage filesystem | Backend |
| 5 | Write unit/integration tests | GnuPG binary | QA |
| 6 | Benchmark vs. Laravel’s encrypt() |
Load testing | Perf |
| 7 | Deploy to staging | CI/CD pipeline | DevOps |
| 8 | Monitor for binary dependency issues | Logging/alerts | SRE |
gnupg binary updates may break the PHP wrapper (e.g., API changes in GnuPG 2.3+).gnupg binary version in Docker or use a version manager (e.g., gpg2).php artisan gnupg:rotate-keys) to automate key generation/revocation.Log facade to track usage (e.g., encryption failures, key access).gpg: decryption failed: No secret key) require familiarity with GnuPG CLI output.--verbose flag to the wrapper or log raw gnupg command output for debugging.trust-model, pinentry) may need hardening. Use tools like gpg --edit-key to audit keys.rsa).How can I help you explore Laravel packages today?