Download the PHP package kariricode/dotenv without Composer
On this page you can find all versions of the php package kariricode/dotenv. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download kariricode/dotenv
More information about kariricode/dotenv
Files in kariricode/dotenv
Package dotenv
Short Description A highly optimized, extensible, and reliable Dotenv component designed to load environment variables for PHP applications in the KaririCode Framework, ensuring secure and efficient configuration management.
License MIT
Homepage https://kariricode.org
Informations about the package dotenv
KaririCode Framework: Dotenv Component
A robust and flexible environment variable management component for the KaririCode Framework, providing advanced features for handling .env files in PHP applications.
Features
- Parse and load environment variables from .env files
- Support for variable interpolation
- Automatic type detection and casting
- Detects and converts common types (string, integer, float, boolean, array, JSON)
- Preserves data types for more accurate usage in your application
- Customizable type system
- Extensible with custom type detectors and casters
- Fine-grained control over how your environment variables are processed
- Strict mode for variable name validation
- Easy access to environment variables through a global helper function
- Support for complex data structures (arrays and JSON) in environment variables
Installation
To install the KaririCode Dotenv component in your project, run the following command:
Usage
Basic Usage
-
Create a
.env
file in your project's root directory: - In your application's bootstrap file:
Type Detection and Casting
The KaririCode Dotenv component automatically detects and casts the following types:
- Strings
- Integers
- Floats
- Booleans
- Null values
- Arrays
- JSON objects
Example:
When accessed using the env()
function, these variables will be automatically cast to their appropriate PHP types:
This automatic typing ensures that you're working with the correct data types in your application, reducing type-related errors and improving overall code reliability.
Advanced Usage
Custom Type Detectors
Create custom type detectors to handle specific formats:
Custom Type Casters
Create custom type casters to handle specific data types:
Development and Testing
For development and testing purposes, this package uses Docker and Docker Compose to ensure consistency across different environments. A Makefile is provided for convenience.
Prerequisites
- Docker
- Docker Compose
- Make (optional, but recommended for easier command execution)
Setup for Development
-
Clone the repository:
-
Set up the environment:
-
Start the Docker containers:
- Install dependencies:
Available Make Commands
make up
: Start all services in the backgroundmake down
: Stop and remove all containersmake build
: Build Docker imagesmake shell
: Access the shell of the PHP containermake test
: Run testsmake coverage
: Run test coverage with visual formattingmake cs-fix
: Run PHP CS Fixer to fix code stylemake quality
: Run all quality commands (cs-check, test, security-check)
For a full list of available commands, run:
License
This project is licensed under the MIT License - see the LICENSE file for details.
Support and Community
- Documentation: https://kariricode.org/docs/dotenv
- Issue Tracker: GitHub Issues
- Community: KaririCode Club Community
Acknowledgments
- The KaririCode Framework team and contributors.
- Inspired by other popular PHP Dotenv libraries.
Built with ❤️ by the KaririCode team. Empowering developers to build more robust and flexible PHP applications.