stillat/proteus
Proteus provides a flexible, developer-friendly way to build and run dynamic “protean” objects in Laravel/PHP. Define behaviors, properties, and runtime composition with a clean API, useful for prototyping, extensible domain models, and data-driven object structures.
stillat/proteus) aligns well with Laravel’s native config/ file structure (PHP arrays with dot notation), making it a natural fit for projects requiring dynamic configuration management outside Laravel’s core. It abstracts file I/O, validation, and merging logic, reducing boilerplate for custom config systems.Config facade or service container. Can replace or extend Laravel’s built-in config() helper for advanced use cases (e.g., live-reloading configs from S3).require or file_get_contents.write() is exposed to untrusted users).ConfigRepository interface, or is a pure PHP solution needed?spatie/laravel-config-array (Laravel-specific) or vlucas/phpdotenv (env-focused).config('key') with Proteus::get('key') for dynamic configs. Use Proteus::write() to persist changes to disk.ConfigServiceProvider via a custom binding:
$this->app->bind('config', function () {
return new ProteusConfigRepository(storage_path('config/dynamic.php'));
});
$config = new \Stillat\Proteus\Proteus('path/to/config.php');
$config->set('database.timeout', 30)->write();
Proteus reads/writes to a shared volume or API.require config/app.php with Proteus::load() in bootstrap/app.php./config API endpoint using Proteus::write() with auth middleware.Route::put('/config/{key}', function ($key, Request $request) {
$config = Proteus::getInstance();
$config->set($key, $request->input())->write();
return response()->json(['status' => 'updated']);
})->middleware('can:admin');
ConfigRepository to use Proteus as the backend.Proteus-managed ones.fileinfo may help with MIME validation.league/flysystem), or custom streams. Ensure IAM permissions for cloud storage.| Step | Priority | Dependencies | Risks |
|---|---|---|---|
| Validate package | P0 | PHP 8.1+, Laravel 10+ | Hypothetical breaking changes |
| Local testing | P0 | Unit tests for CRUD ops | Edge cases (e.g., nested arrays) |
| API integration | P1 | Auth middleware | Rate-limiting for writes |
| CI/CD pipeline | P1 | GitHub Actions/Docker | Config drift in deployments |
| Monitoring | P2 | Laravel Horizon/Sentry | Unauthorized config edits |
Proteus::write() calls to track changes (e.g., with Laravel’s Log::channel('config')).app/storage.Proteus::getStructure() to dump the parsed config tree for troubleshooting.proteus:validate Artisan command to check for required keys.revert method or use Git to restore configs:
git checkout HEAD -- config/dynamic.php
config/schema.php file (validated via Proteus::validate()).Proteus as the source of truth.app memory (e.g., static $cache = [];).| Scenario | Impact | Mitigation |
|---|---|---|
| Config file corruption | App crashes on missing keys | Fallback to config/default.php |
| Permission denied (write) | Dynamic updates fail | Use umask(000) or ACLs |
| Disk full | write() throws DiskFull |
Monitor storage with Laravel Forge |
| Network failure (S3) | Config load hangs | Fallback to local cache |
| Malicious config injection | RCE via include |
Whitelist allowed keys/values |
Proteus methods (get, set, validate).config/app.php to Proteus in 3 steps.Proteus instances; use dependency injection.How can I help you explore Laravel packages today?