根據(jù)webman文檔中的打包,我已經(jīng)把項(xiàng)目打包到build/program.phar
但是運(yùn)行這個(gè)打包后,發(fā)現(xiàn)并不是讀取.env配置的。 我試著把.env文件放到program.phar同級(jí)目錄下,依舊不行。
下面是我的.env配置:
NAME=program
DEBUG=true
LISTEN=http://192.168.10.10:8787
這是config/app.php配置
return [
'debug' => env('DEBUG',true),
'default_timezone' => 'Asia/Shanghai',
];
這是config/server.php配置
return [
'listen' => env('LISTEN','http://0.0.0.0:8787'),
'transport' => env('TRANSPORT','tcp'),
'context' => [],
'name' => env('NAME',''),
'count' => env('HTTP_PROCESS_COUNT',cpu_count() * 2),
'user' => 'root',
'group' => 'root',
'reusePort' => false,
'pid_file' => runtime_path() . '/webman.pid',
'status_file' => runtime_path() . '/webman.status',
'stdout_file' => runtime_path() . '/logs/stdout.log',
'log_file' => runtime_path() . '/logs/workerman.log',
'max_package_size' => 10*1024*1024
];
這是config/plugin/webman/console/app.php
return [
'enable' => true,
'phar_file_output_dir' => BASE_PATH . DIRECTORY_SEPARATOR . 'build',
'phar_filename' => 'program.phar',
'signature_algorithm'=> Phar::SHA256, //set the signature algorithm for a phar and apply it. The signature algorithm must be one of Phar::MD5, Phar::SHA1, Phar::SHA256, Phar::SHA512, or Phar::OPENSSL.
'private_key_file' => '', // The file path for certificate or OpenSSL private key file.
'exclude_pattern' => '#^(?!.*(config/plugin/webman/console/app.php|webman/console/src/Commands/(PharPackCommand.php|ReloadCommand.php)|LICENSE|composer.json|.github|.idea|doc|docs|.git|.setting|runtime|test|test_old|tests|Tests|vendor-bin|.md))(.*)$#',
'exclude_files' => [
'.env', 'LICENSE', 'composer.json', 'composer.lock','start.php'
]
];
以上配置執(zhí)行php start.php start 都是正常讀取.env配置的
打包后,只能讀取到env()函數(shù)的默認(rèn)值
感謝幫忙看一下
config/plugin/webman/console/app.php 的 exclude_files 里
'exclude_files' => [
'.env', 'LICENSE', 'composer.json', 'composer.lock','start.php'
]
'.env' 去掉試下呢?