❌

Normal view

I built AmunCode Config — a lightweight configuration and environment-loading library for PHP

Hey everyone!

I've been working on a small PHP library called AmunCode Config, and I'm sharing its first stable release.

The idea is simple: provide a lightweight, framework-independent way to load environment variables, load PHP configuration files, and access configuration values without introducing a large framework or unnecessary abstractions.

What does it provide?

The package currently has four main classes:

  • EnvironmentLoader — loads .env files using PHP dotenv, with optional or required file loading.
  • Env — retrieves environment variables from $_ENV, $_SERVER, and getenv(), with automatic value normalization.
  • ConfigurationLoader — discovers and loads PHP configuration files from a directory.
  • Config — provides dot-notation access to configuration values, including retrieving, updating, and recursively merging configuration arrays.

A quick example

use AmunCode\Config\Config; use AmunCode\Config\EnvironmentLoader; // Load environment variables. $environment = new EnvironmentLoader(); $environment->load($root); // Load PHP configuration files. $config = new Config($root . '/config'); // Retrieve configuration values. $appName = $config->get('app.name', 'My Application'); $dbHost = $config->get('database.host'); // Update configuration. $config->set('app.debug', true); 

A few design decisions:

  • Environment loading and configuration loading are separate operations.
  • Environment variables are not overwritten by .env values when already defined.
  • Empty environment values are preserved rather than silently replaced by defaults.
  • The package doesn't automatically define a global env() helper.

Technical details

  • PHP 8.4.1+
  • Symfony Finder
  • PHP dotenv
  • Composer package
  • MIT License
  • PHPUnit tests and GitHub Actions CI

Installation

composer require amuncode/config 

Source code: https://github.com/AmunCode-OSS/Config

Documentation and usage examples are available in the repository README.

I'd appreciate feedback from other PHP developers, particularly on the API design, class responsibilities, and whether anything important is missing or could be simpler.

Thanks for taking a look!

submitted by /u/AmunCode to r/PHP
[link] [comments]

What an AI agent needs from a PHP framework to write code you can actually trust

I'm the author of Kinetis ( https://kinetis.dev/ ), a PHP framework for persistent workers. I wrote up an experiment: AI agents built a small JSON API from a fresh skeleton in about 15 minutes, with 50 tests, a clean PHPStan run and an independent review.

My takeaway: speed isn't the hard part, trust is. What made this run's output checkable:

  • The agent read the installed package versions and vendor source, not what it remembered from training.
  • The reviewer cited a file and line for every claim.
  • The endpoint code is declarative (readonly DTO + backed enum), so there's little to get wrong and little to review.

Full write-up and video: https://kinetis.dev/blog/posts/rest-api-in-15-minutes-kinetis-orbitron.html

Would you trust this workflow in a real codebase? What would you want a framework to expose to agents?

submitted by /u/Normal_Tadpole_8061 to r/PHP
[link] [comments]
❌