phpdotenv

Laravel 5 Dotenv for specific subdomain

独自空忆成欢 提交于 2019-12-04 11:23:07
I have a few subdomain in my laravel 5 application, each sub domain have a specific configuration, like mail, nocaptcha, etc. how to set .env file to work with my-specific subdomain ? Yes, you can use separate .env files for each subdomain so if you use env variables in your config it will work without great modifications. Create bootstrap/env.php file with the following content: <?php $app->detectEnvironment(function () use ($app) { if (!isset($_SERVER['HTTP_HOST'])) { Dotenv::load($app['path.base'], $app->environmentFile()); } $pos = mb_strpos($_SERVER['HTTP_HOST'], '.'); $prefix = ''; if (

Fatal error: Class 'Dotenv\Dotenv' not found in

荒凉一梦 提交于 2019-12-04 04:53:40
问题 Hello guys I am so confused I dont know what I am doing wrong this told me Fatal error: Class 'Dotenv\Dotenv' not found in But I dont understand why.. $dotenv = new \Dotenv\Dotenv(dirname(dirname(dirname(dirname(__DIR__))))); $dotenv->load(); My structure is the next and in the file index.php is where I am calling Dotenv also I used use Dotenv\Dotenv; but it doesnt work too. 回答1: Be sure that you are using Dotenv after loading from vendor/autoload.php . For example, I was using OpenCart, in

How to specify a different .env file for phpunit in Laravel 5?

别说谁变了你拦得住时间么 提交于 2019-12-03 08:30:01
问题 I have a .env file containing my database connection details, as is normal for Laravel 5. I want to override these for testing, which I can do in phpunit.xml . However, doing this seems to go against the philosophy of .env which is not to commit environmental configurations, particularly passwords. Is it possible to have something like .env.testing and tell phpunit.xml to read from that? 回答1: Copy your .env to .env.testing , then edit the .env.testing file and change the APP_ENV parameter to

How to specify a different .env file for phpunit in Laravel 5?

淺唱寂寞╮ 提交于 2019-12-03 01:28:53
I have a .env file containing my database connection details, as is normal for Laravel 5. I want to override these for testing, which I can do in phpunit.xml . However, doing this seems to go against the philosophy of .env which is not to commit environmental configurations, particularly passwords. Is it possible to have something like .env.testing and tell phpunit.xml to read from that? Copy your .env to .env.testing , then edit the .env.testing file and change the APP_ENV parameter to make it like this APP_ENV=testing this way you will be able to specify your settings int this new file In

Fatal error: Class 'Dotenv\\Dotenv' not found in

北城以北 提交于 2019-12-02 02:10:13
Hello guys I am so confused I dont know what I am doing wrong this told me Fatal error: Class 'Dotenv\Dotenv' not found in But I dont understand why.. $dotenv = new \Dotenv\Dotenv(dirname(dirname(dirname(dirname(__DIR__))))); $dotenv->load(); My structure is the next and in the file index.php is where I am calling Dotenv also I used use Dotenv\Dotenv; but it doesnt work too. Be sure that you are using Dotenv after loading from vendor/autoload.php . For example, I was using OpenCart, in which contained a file startup.php with: // Autoloader if (file_exists(DIR_VENDOR . 'autoload.php')) {

What is difference between use env('APP_ENV'), config('app.env') or App::environment() to get app environment?

▼魔方 西西 提交于 2019-11-27 19:11:30
问题 What is difference between use env('APP_ENV') , config('app.env') or App::environment() to get app environment? I know that the env('APP_ENV') will to $_ENV , config('app.env') reads the configuration and App::environment() is an abstraction of all. And in my opinion the advantage is even this. Abstraction . I do not know if there are other differences, such as the level of performance or security 回答1: In Short & up-to-date 2019: - use env() only in config files - use App::environment() for

Laravel 5 - env() always returns null

ぐ巨炮叔叔 提交于 2019-11-27 01:13:42
问题 I try to find out why my env() helper always returns null . This causes trouble especially in app.php file, where are env() helpers widely used by default. Perhaps any mysterious server setting? My env file : APP_ENV=production APP_KEY=base64:mymagickey= APP_DEBUG=false APP_LOG_LEVEL=info APP_URL=http://www.example.com etc... EDIT - I tried following : php artisan cache:clear php artisan view:clear php artisan config:cache and ofcourse, i am using env helper like this: env('APP_ENV') But