tina4stack/tina4php-env

Tina4 PHP Environment Functionality

Maintainers

Package info

github.com/tina4stack/tina4php-env

pkg:composer/tina4stack/tina4php-env

Statistics

Installs: 7 123

Dependents: 2

Suggesters: 0

Stars: 3

Open Issues: 0

v2.0.9 2026-03-14 18:22 UTC

This package is auto-updated.

Last update: 2026-03-14 19:34:35 UTC


README

Environment variable loader for the Tina4 PHP framework, reading .env files and exposing values as PHP constants and $_ENV entries.

Installation

composer require tina4stack/tina4php-env

Requirements

  • PHP >= 8.1

Usage

Basic .env File

Create a .env file in your project root:

[Database]
DB_HOST=localhost
DB_PORT=3306
DB_NAME=myapp

[App]
APP_DEBUG=true
VERSION=1.0.0

Loading the Environment

use Tina4\Env;

// Loads .env from the project root
new Env();

// Access variables as constants or via $_ENV
echo DB_HOST;          // "localhost"
echo $_ENV["DB_NAME"]; // "myapp"

Environment-Specific Files

Set an ENVIRONMENT OS variable to load .env.{ENVIRONMENT} instead:

// If ENVIRONMENT=staging, loads .env.staging
new Env();

// Or force a specific environment
new Env("production"); // loads .env.production

Testing

composer test

License

MIT - see LICENSE

Our Sponsors

Sponsored with 🩵 by Code Infinity

Code Infinity

Supporting open source communities • Innovate • Code • Empower