Environments of Phspark

The role of the .env file is to allow you to have different settings depending on which machine you are running your application. So on your production server, the .env file settings would be different from your local development environment.

In development (coding) environment use this settings:

APP_ENV=local

* When you will set your environment as ``APP_ENV=local``. Phspark will search for a file env/local.php and reset/add all the env variables called there.

In the production (server) use this settings:

APP_ENV=production

* When you will set your environment as ``APP_ENV=production``. Phspark will search for a file env/production.php and reset/add all the env variables called there.

Possible contents of env/product.php file
        <?php
        resetenv('DB_DATABASE', 'new_database')
        ...

The APP_ENV flag is not a boolean, this is because you can have many environments in your project, for example, production, development, staging, testing, etc. You can “change” the behavior of the app while you are in a specific environment. For example if you are working with PayPal, you don’t want to charge real money while you are building the application, then you can use the flag in order to switch between your sandbox and production credentials:

<?php
class PayPalCheckout {
        private $url;
        private $apiKey;
        private $secret;
        public function __construct() {
                if (env('APP_ENV') === 'production') {
                        // Initialize the attribute for production
                } else {
                        // Initialize the attributes for sandbox
                }
        }
}