A contract-only PHP library that defines the DotEnvInterface for Domain-Driven Design applications.
This package provides exclusively an interface – no implementation. It serves as an abstraction layer for DotEnv functionality and distinguishes between:
- Public environment variables (system-wide, loaded into
$_ENV) - Private environment variables (application-specific, returned as an array)
composer require jardisport/dotenvnamespace JardisPort\DotEnv;
interface DotEnvInterface
{
/**
* Loads public environment variables into the system environment ($_ENV, getenv)
*
* @param string $pathToEnvFiles Path to directory containing .env files
* @throws Exception
*/
public function loadPublic(string $pathToEnvFiles): void;
/**
* Loads and returns private environment variables as an array
*
* @param string $pathToEnvFiles Path to directory containing .env files
* @return array<string, mixed>|null
* @throws Exception
*/
public function loadPrivate(string $pathToEnvFiles): mixed;
}Implement the interface in your own class:
use JardisPort\DotEnv\DotEnvInterface;
class MyDotEnv implements DotEnvInterface
{
public function loadPublic(string $pathToEnvFiles): void
{
// Implementation for loading public variables
}
public function loadPrivate(string $pathToEnvFiles): mixed
{
// Implementation for loading private variables
return $privateVars;
}
}This project uses Docker for all development tasks. Never run Composer, PHPStan, or PHPCS commands directly on the host – always use the Makefile targets.
- Docker
- Docker Compose
- Make
# Install dependencies
make install
# Update dependencies
make update
# Regenerate autoloader
make autoload
# Check code style (PSR-12)
make phpcs
# Run static analysis (PHPStan Level 8)
make phpstan
# Open container shell
make shell
# Clean up Docker resources
make remove- Standard: PSR-12
- Line length: 120 (limit), 150 (absolute limit)
- Strict types required:
declare(strict_types=1);
- Level: 8 (maximum strictness)
- Analyzed paths:
src/
After installation, a Git pre-commit hook is automatically set up that:
- Validates branch names:
(feature|fix|hotfix)/{1-7 digits}_{description}or:{7-40 hex chars} - Validates Git username
- Runs PHPCS on staged PHP files
- Blocks commits on errors
- Minimum: PHP 8.2
- Recommended: PHP 8.3
This project follows Semantic Versioning. Since this is a contract, breaking changes are rare and only appear in major versions.
MIT License - see LICENSE for details.
- Issues: GitHub Issues
- Email: jardisCore@headgent.dev
Jardis Core Development Team