Skip to content

Commit

Permalink
new version
Browse files Browse the repository at this point in the history
  • Loading branch information
oscarotero committed Dec 3, 2024
1 parent 8ff53b2 commit 9f7d85c
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 28 deletions.
4 changes: 2 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).

## [2.1.1] - Unreleased
## [2.1.1] - 2024-12-03
### Fixed
- Support for PHP 8.4 [#12].

Expand Down Expand Up @@ -54,7 +54,7 @@ First stable version
[#8]: https://github.com/oscarotero/env/issues/8
[#12]: https://github.com/oscarotero/env/issues/12

[2.1.1]: https://github.com/oscarotero/env/compare/v2.1.0...HEAD
[2.1.1]: https://github.com/oscarotero/env/compare/v2.1.0...v2.1.1
[2.1.0]: https://github.com/oscarotero/env/compare/v2.0.0...v2.1.0
[2.0.0]: https://github.com/oscarotero/env/compare/v1.2.0...v2.0.0
[1.2.0]: https://github.com/oscarotero/env/compare/v1.1.0...v1.2.0
Expand Down
49 changes: 23 additions & 26 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
# env

[![Software License][ico-license]](LICENSE)
[![Build Status][ico-travis]][link-travis]
[![Quality Score][ico-scrutinizer]][link-scrutinizer]
[![Total Downloads][ico-downloads]][link-downloads]


Simple library to get environment variables converted to simple types.

## Installation

This package is installable and autoloadable via Composer as [oscarotero/env](https://packagist.org/packages/oscarotero/env).
This package is installable and autoloadable via Composer as
[oscarotero/env](https://packagist.org/packages/oscarotero/env).

```
$ composer require oscarotero/env
```sh
composer require oscarotero/env
```

## Example
Expand All @@ -30,26 +28,29 @@ var_dump(Env::get('FOO')); //bool(false)

## Available conversions

* `"false"` is converted to boolean `false`
* `"true"` is converted to boolean `true`
* `"null"` is converted to `null`
* If the string contains only numbers is converted to an integer
* If the string has quotes, remove them
- `"false"` is converted to boolean `false`
- `"true"` is converted to boolean `true`
- `"null"` is converted to `null`
- If the string contains only numbers is converted to an integer
- If the string has quotes, remove them

## Options

To configure the conversion, you can use the following constants (all enabled by default):
To configure the conversion, you can use the following constants (all enabled by
default):

* `Env::CONVERT_BOOL` To convert boolean values
* `Env::CONVERT_NULL` To convert null values
* `Env::CONVERT_INT` To convert integer values
* `Env::STRIP_QUOTES` To remove the quotes of the strings
- `Env::CONVERT_BOOL` To convert boolean values
- `Env::CONVERT_NULL` To convert null values
- `Env::CONVERT_INT` To convert integer values
- `Env::STRIP_QUOTES` To remove the quotes of the strings

There's also additional settings that you can enable (they're disabled by default)
There's also additional settings that you can enable (they're disabled by
default)

* `Env::USE_ENV_ARRAY` To get the values from `$_ENV`, instead `getenv()`.
* `Env::USE_SERVER_ARRAY` To get the values from `$_SERVER`, instead `getenv()`.
* `Env::LOCAL_FIRST` To get first the values of locally-set environment variables.
- `Env::USE_ENV_ARRAY` To get the values from `$_ENV`, instead `getenv()`.
- `Env::USE_SERVER_ARRAY` To get the values from `$_SERVER`, instead `getenv()`.
- `Env::LOCAL_FIRST` To get first the values of locally-set environment
variables.

```php
use Env\Env;
Expand All @@ -66,7 +67,8 @@ Env::$options ^= Env::CONVERT_NULL;

## Default value

By default, if the value does not exist, returns `null`, but you can change for any other value:
By default, if the value does not exist, returns `null`, but you can change for
any other value:

```php
use Env\Env;
Expand All @@ -91,10 +93,5 @@ Please see [CHANGELOG](CHANGELOG.md) for more information about recent changes.
The MIT License (MIT). Please see [LICENSE](LICENSE) for more information.

[ico-license]: https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square
[ico-travis]: https://img.shields.io/travis/oscarotero/env/master.svg?style=flat-square
[ico-scrutinizer]: https://img.shields.io/scrutinizer/g/oscarotero/env.svg?style=flat-square
[ico-downloads]: https://img.shields.io/packagist/dt/oscarotero/env.svg?style=flat-square

[link-travis]: https://travis-ci.org/oscarotero/env
[link-scrutinizer]: https://scrutinizer-ci.com/g/oscarotero/env
[link-downloads]: https://packagist.org/packages/oscarotero/env

0 comments on commit 9f7d85c

Please sign in to comment.