Download the PHP package bnomei/kirby3-dotenv without Composer

On this page you can find all versions of the php package bnomei/kirby3-dotenv. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package kirby3-dotenv

Kirby DotEnv

Kirby 5 PHP 8.2 Release Downloads Coverage Maintainability Discord Buymecoffee

Kirby Plugin for environment variables from .env files

Installation

Usage

Create a .env file in the root of your Kirby installation. Within your Kirby project you can access the environment variables using various PHP helper functions.

in production or with default environment

Based on an environment like

/.env

on local or staging test server

You can also create files to have different settings for different environments. The plugin will try to automatically load the correct file based on the environment.

Based on an environment like

/.env.dotenv.test

Default values

In case you want to provide a default value as fallback in case the environment variable is not set you can do that with the 2nd parameter in each helper function. Thanks for your PR @teichsta.

Usage in Config files might require a manual load

The environment variables set by your hosting service are available in your PHP scripts by default using the $_ENV super-global and the getenv() function. They are injected into the PHP environment by the web server.

But the values from the .env files are NOT available in the same way. They need to be loaded manually. The Dotenv plugin will load these on it's first usage. But the plugin can only do so automatically once it has been loaded itself which is after the config files have been parsed by Kirby.

Using Callbacks or the Ready Option

Where possible you should use the callback option to provide a function that returns the value you need. Once the callback is called the .env file will already have been loaded and the value will be available. Not all options support callbacks though.

/site/config/config.php

Manually load the .env file in the config file

If you still decide you need to use the values from the .env files in the config files of Kirby directly, you can manually initialize the loading of these like so:

/site/config/config.php

You can provide a custom options as an array to that function if you want to force loading a specific directory or file.

Other Environment Variables Sources

If you set environment variables in your server configuration these will be available as well.

[!WARNING] This plugin will load environment variables from .env files and potentially overwrite existing environment variables.

In the CLI

When running Kirby commands in the CLI make sure you prefix the command with the environment variable for the HOST you want to use.

Similar Plugins

Settings

bnomei.dotenv. Default Description
dir callback returning kirby()->roots()->index(). When installing Kirby 3 with Composer use a function() { return realpath(kirby()->roots()->index() . '/../'); }
file .env
environment callback auto-detection for the current environment
required callback or [] You can define required variables in the settings using an array. If any of these is missing a RuntimeException will be thrown.
setup callback perform additional tasks on raw dotenv class instance

Dependencies

Disclaimer

This plugin is provided "as is" with no guarantee. Use it at your own risk and always test it yourself before using it in a production environment. If you find any issues, please create a new issue.

License

MIT

It is discouraged to use this plugin in any project that promotes racism, sexism, homophobia, animal abuse, violence or any other form of hate speech.

Credits

based on K2 version of


All versions of kirby3-dotenv with dependencies

PHP Build Version
Package Version
Requires php Version >=8.2
getkirby/composer-installer Version ^1.1
vlucas/phpdotenv Version ^5.3
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package bnomei/kirby3-dotenv contains the following files

Loading the files please wait ....