PHP Classes

How to Perform a PHP Env File Export Using the Package PHP Env Export: Export environment variables to a file

Recommend this page to a friend!
     
  Info   View files Files   Install with Composer Install with Composer   Download Download   Reputation   Support forum   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2024-05-18 (3 months ago) RSS 2.0 feedNot yet rated by the usersTotal: 33 All time: 11,051 This week: 71Up
Version License PHP version Categories
php-env-export 1.0The PHP License5PHP 5, Libraries, Configuration, Desi..., G...
Description 

Author

This package can export environment variables to a file.

It provides a global function that can export the values of environment variables to a given file.

The package also provides a Laravel service class that can call the function export environment variable values, so the function can be made available as a service for Laravel applications.

Innovation Award
PHP Programming Innovation award nominee
May 2024
Number 6
Environment variables are values associated with names that are usually stored in environment variable files.

Environment variable files are text files that are easy to write and read by humans.

Many developers like to use environment variable files to share configuration values between different parts of an application, even when each part is developed using a different programming language.

This package provides a function to export the values of environment variables of a PHP application to a given file.

This way the current values can be shared with multiple parts of an application.

Manuel Lemos
Picture of Zacchaeus Bolaji
  Performance   Level  
Name: Zacchaeus Bolaji <contact>
Classes: 17 packages by
Country: Nigeria Nigeria
Age: ???
All time rank: 245415 in Nigeria Nigeria
Week rank: 181 Up5 in Nigeria Nigeria Up
Innovation award
Innovation award
Nominee: 12x

Winner: 1x

Details

PHP Env Export

CircleCI Latest Stable Version Total Downloads License Build Status Scrutinizer Code Quality

PHP Package to export env keys to new file

Installation

You can install the package via composer:

composer require --dev djunehor/php-env-export

Laravel 5.5 and above

The package will automatically register itself, so you can start using it immediately.

Laravel 5.4 and older

In Laravel version 5.4 and older, you have to add the service provider in config/app.php file manually:

'providers' => [
    // ...
    Djunehor\Env\EnvExportServiceProvider::class,
];

Lumen

After installing the package, you will have to register it in bootstrap/app.php file manually:

// Register Service Providers
    // ...
    $app->register(Djunehor\Env\EnvExportServiceProvider::class);
];

Usage

via helper method

$from = '.env'; //default value is .env
$to = '.env.example'; // default value is .env.example
export_env($from, $to);

Via Laravel Artisan Command

  • `php artisan env:export` uses default values
  • Or `php artisan env:export --from=.env --to='.env.example`
  • Or `php artisan env:export -f=.env -to='.env.example`

Via Console/Terminal

  • At the root of your application, run `php --run "require 'vendor/djunehor/php-env-export/src/Export.php'; export_env();"`

Contributing

  • Fork this project
  • Clone to your repo
  • Make your changes and run tests `composer test`
  • Push and create a pull request

  Files folder image Files (13)  
File Role Description
Files folder image.circleci (1 file)
Files folder imagesrc (3 files)
Files folder imagetests (2 files)
Accessible without login Plain text file .env.testing Data Auxiliary data
Accessible without login Plain text file .scrutinizer.yml Data Auxiliary data
Accessible without login Plain text file .styleci.yml Data Auxiliary data
Accessible without login Plain text file composer.json Data Auxiliary data
Accessible without login Plain text file LICENSE Lic. License text
Accessible without login Plain text file phpunit.xml Data Auxiliary data
Accessible without login Plain text file README.md Doc. Documentation

  Files folder image Files (13)  /  .circleci  
File Role Description
  Accessible without login Plain text file config.yml Data Auxiliary data

  Files folder image Files (13)  /  src  
File Role Description
  Plain text file EnvExportServiceProvider.php Class Class source
  Accessible without login Plain text file Export.php Aux. Auxiliary script
  Plain text file ExportCommand.php Class Class source

  Files folder image Files (13)  /  tests  
File Role Description
  Plain text file EnvExportTest.php Class Class source
  Plain text file TestCase.php Class Class source

The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page.
Install with Composer Install with Composer
 Version Control Unique User Downloads Download Rankings  
 100%
Total:33
This week:0
All time:11,051
This week:71Up