phar打包后出现问题

ss544325999

问题描述

疑似env文件未读取到,mac,php7.2.34.云redis

程序代码

<?php
return [
    'enable' => true,

    'build_dir'  => BASE_PATH . DIRECTORY_SEPARATOR . 'build',

    'phar_filename' => 'webman.phar',

    'bin_filename' => 'webman.bin',

    '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'   => '#^(?!.*(composer.json|/.github/|/.idea/|/.git/|/.setting/|/runtime/|/vendor-bin/|/build/|/vendor/webman/admin/))(.*)$#',

    'exclude_files'     => [
        '.env', 'LICENSE', 'composer.json', 'composer.lock', 'start.php', 'webman.phar', 'webman.bin'
    ]
];

报错信息

[2023-03-20 09:56:08] default.ERROR: 127.0.0.1 POST localhost:8788/leads
ErrorException: Redis::connect(): php_network_getaddresses: getaddrinfo failed: nodename nor servname provided, or not known in phar:///Users/xiaoyinka/www/webman/build/webman.phar/vendor/illuminate/redis/Connectors/PhpRedisConnector.php:137
Stack trace:
#0 [internal function]: support\App::{closure}(2, 'Redis::connect(...', 'phar:///Users/x...', 137, Array)
#1 phar:///Users/xiaoyinka/www/webman/build/webman.phar/vendor/illuminate/redis/Connectors/PhpRedisConnector.php(137): Redis->connect('', false, 0, NULL, 0, 0)
#2 phar:///Users/xiaoyinka/www/webman/build/webman.phar/vendor/illuminate/redis/Connectors/PhpRedisConnector.php(84): Illuminate\Redis\Connectors\PhpRedisConnector->establishConnection(Object(Redis), Array)
#3 phar:///Users/xiaoyinka/www/webman/build/webman.phar/vendor/illuminate/support/helpers.php(433): Illuminate\Redis\Connectors\PhpRedisConnector->Illuminate\Redis\Connectors\{closure}(Object(Redis))
#4 phar:///Users/xiaoyinka/www/webman/build/webman.phar/vendor/illuminate/redis/Connectors/PhpRedisConnector.php(105): tap(Object(Redis), Object(Closure))
#5 phar:///Users/xiaoyinka/www/webman/build/webman.phar/vendor/illuminate/redis/Connectors/PhpRedisConnector.php(28): Illuminate\Redis\Connectors\PhpRedisConnector->createClient(Array)
#6 phar:///Users/xiaoyinka/www/webman/build/webman.phar/vendor/illuminate/redis/Connectors/PhpRedisConnector.php(32): Illuminate\Redis\Connectors\PhpRedisConnector->Illuminate\Redis\Connectors\{closure}()
#7 phar:///Users/xiaoyinka/www/webman/build/webman.phar/vendor/illuminate/redis/RedisManager.php(111): Illuminate\Redis\Connectors\PhpRedisConnector->connect(Array, Array)
#8 phar:///Users/xiaoyinka/www/webman/build/webman.phar/vendor/illuminate/redis/RedisManager.php(90): Illuminate\Redis\RedisManager->resolve('default')
#9 phar:///Users/xiaoyinka/www/webman/build/webman.phar/vendor/workerman/webman-framework/src/support/Redis.php(262): Illuminate\Redis\RedisManager->connection('default')
#10 phar:///Users/xiaoyinka/www/webman/build/webman.phar/vendor/workerman/webman-framework/src/support/Cache.php(35): support\Redis::connection()
#11 phar:///Users/xiaoyinka/www/webman/build/webman.phar/vendor/workerman/webman-framework/src/support/Cache.php(48): support\Cache::instance()
#12 phar:///Users/xiaoyinka/www/webman/build/webman.phar/app/model/ConfBase.php(38): support\Cache::__callStatic('has', Array)
#13 phar:///Users/xiaoyinka/www/webman/build/webman.phar/app/controller/LeadsController.php(23): app\model\ConfBase->listOpt(Array)
#14 phar:///Users/xiaoyinka/www/webman/build/webman.phar/vendor/workerman/webman-framework/src/App.php(318): app\controller\LeadsController->push(Object(support\Request))
#15 phar:///Users/xiaoyinka/www/webman/build/webman.phar/vendor/workerman/webman-framework/src/App.php(559): Webman\App::Webman\{closure}(Object(support\Request))
#16 phar:///Users/xiaoyinka/www/webman/build/webman.phar/vendor/workerman/webman-framework/src/App.php(148): Webman\App::findRoute(Object(Workerman\Connection\TcpConnection), '/leads', 'POST/leads', Object(support\Request))
#17 phar:///Users/xiaoyinka/www/webman/build/webman.phar/vendor/workerman/workerman/Connection/TcpConnection.php(646): Webman\App->onMessage(Object(Workerman\Connection\TcpConnection), Object(support\Request))
#18 phar:///Users/xiaoyinka/www/webman/build/webman.phar/vendor/workerman/workerman/Events/Select.php(311): Workerman\Connection\TcpConnection->baseRead(Resource id #512)
#19 phar:///Users/xiaoyinka/www/webman/build/webman.phar/vendor/workerman/workerman/Worker.php(1629): Workerman\Events\Select->loop()
#20 phar:///Users/xiaoyinka/www/webman/build/webman.phar/vendor/workerman/workerman/Worker.php(1423): Workerman\Worker::forkOneWorkerForLinux(Object(Workerman\Worker))
#21 phar:///Users/xiaoyinka/www/webman/build/webman.phar/vendor/workerman/workerman/Worker.php(1397): Workerman\Worker::forkWorkersForLinux()
#22 phar:///Users/xiaoyinka/www/webman/build/webman.phar/vendor/workerman/workerman/Worker.php(560): Workerman\Worker::forkWorkers()
#23 phar:///Users/xiaoyinka/www/webman/build/webman.phar/vendor/workerman/webman-framework/src/support/App.php(131): Workerman\Worker::runAll()
#24 phar:///Users/xiaoyinka/www/webman/build/webman.phar/vendor/webman/console/src/Commands/StartCommand.php(29): support\App::run()
#25 phar:///Users/xiaoyinka/www/webman/build/webman.phar/vendor/symfony/console/Command/Command.php(298): Webman\Console\Commands\StartCommand->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#26 phar:///Users/xiaoyinka/www/webman/build/webman.phar/vendor/symfony/console/Application.php(1040): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#27 phar:///Users/xiaoyinka/www/webman/build/webman.phar/vendor/symfony/console/Application.php(301): Symfony\Component\Console\Application->doRunCommand(Object(Webman\Console\Commands\StartCommand), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#28 phar:///Users/xiaoyinka/www/webman/build/webman.phar/vendor/symfony/console/Application.php(171): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#29 phar:///Users/xiaoyinka/www/webman/build/webman.phar/webman(45): Symfony\Component\Console\Application->run()
#30 /Users/xiaoyinka/www/webman/build/webman.phar(5): require('phar:///Users/x...')
#31 {main}

Next RedisException: php_network_getaddresses: getaddrinfo failed: nodename nor servname provided, or not known in phar:///Users/xiaoyinka/www/webman/build/webman.phar/vendor/illuminate/redis/Connectors/PhpRedisConnector.php:137
Stack trace:
#0 phar:///Users/xiaoyinka/www/webman/build/webman.phar/vendor/illuminate/redis/Connectors/PhpRedisConnector.php(137): Redis->connect('', false, 0, NULL, 0, 0)
#1 phar:///Users/xiaoyinka/www/webman/build/webman.phar/vendor/illuminate/redis/Connectors/PhpRedisConnector.php(84): Illuminate\Redis\Connectors\PhpRedisConnector->establishConnection(Object(Redis), Array)
#2 phar:///Users/xiaoyinka/www/webman/build/webman.phar/vendor/illuminate/support/helpers.php(433): Illuminate\Redis\Connectors\PhpRedisConnector->Illuminate\Redis\Connectors\{closure}(Object(Redis))
#3 phar:///Users/xiaoyinka/www/webman/build/webman.phar/vendor/illuminate/redis/Connectors/PhpRedisConnector.php(105): tap(Object(Redis), Object(Closure))
#4 phar:///Users/xiaoyinka/www/webman/build/webman.phar/vendor/illuminate/redis/Connectors/PhpRedisConnector.php(28): Illuminate\Redis\Connectors\PhpRedisConnector->createClient(Array)
#5 phar:///Users/xiaoyinka/www/webman/build/webman.phar/vendor/illuminate/redis/Connectors/PhpRedisConnector.php(32): Illuminate\Redis\Connectors\PhpRedisConnector->Illuminate\Redis\Connectors\{closure}()
#6 phar:///Users/xiaoyinka/www/webman/build/webman.phar/vendor/illuminate/redis/RedisManager.php(111): Illuminate\Redis\Connectors\PhpRedisConnector->connect(Array, Array)
#7 phar:///Users/xiaoyinka/www/webman/build/webman.phar/vendor/illuminate/redis/RedisManager.php(90): Illuminate\Redis\RedisManager->resolve('default')
#8 phar:///Users/xiaoyinka/www/webman/build/webman.phar/vendor/workerman/webman-framework/src/support/Redis.php(262): Illuminate\Redis\RedisManager->connection('default')
#9 phar:///Users/xiaoyinka/www/webman/build/webman.phar/vendor/workerman/webman-framework/src/support/Cache.php(35): support\Redis::connection()
#10 phar:///Users/xiaoyinka/www/webman/build/webman.phar/vendor/workerman/webman-framework/src/support/Cache.php(48): support\Cache::instance()
#11 phar:///Users/xiaoyinka/www/webman/build/webman.phar/app/model/ConfBase.php(38): support\Cache::__callStatic('has', Array)
#12 phar:///Users/xiaoyinka/www/webman/build/webman.phar/app/controller/LeadsController.php(23): app\model\ConfBase->listOpt(Array)
#13 phar:///Users/xiaoyinka/www/webman/build/webman.phar/vendor/workerman/webman-framework/src/App.php(318): app\controller\LeadsController->push(Object(support\Request))
#14 phar:///Users/xiaoyinka/www/webman/build/webman.phar/vendor/workerman/webman-framework/src/App.php(559): Webman\App::Webman\{closure}(Object(support\Request))
#15 phar:///Users/xiaoyinka/www/webman/build/webman.phar/vendor/workerman/webman-framework/src/App.php(148): Webman\App::findRoute(Object(Workerman\Connection\TcpConnection), '/leads', 'POST/leads', Object(support\Request))
#16 phar:///Users/xiaoyinka/www/webman/build/webman.phar/vendor/workerman/workerman/Connection/TcpConnection.php(646): Webman\App->onMessage(Object(Workerman\Connection\TcpConnection), Object(support\Request))
#17 phar:///Users/xiaoyinka/www/webman/build/webman.phar/vendor/workerman/workerman/Events/Select.php(311): Workerman\Connection\TcpConnection->baseRead(Resource id #512)
#18 phar:///Users/xiaoyinka/www/webman/build/webman.phar/vendor/workerman/workerman/Worker.php(1629): Workerman\Events\Select->loop()
#19 phar:///Users/xiaoyinka/www/webman/build/webman.phar/vendor/workerman/workerman/Worker.php(1423): Workerman\Worker::forkOneWorkerForLinux(Object(Workerman\Worker))
#20 phar:///Users/xiaoyinka/www/webman/build/webman.phar/vendor/workerman/workerman/Worker.php(1397): Workerman\Worker::forkWorkersForLinux()
#21 phar:///Users/xiaoyinka/www/webman/build/webman.phar/vendor/workerman/workerman/Worker.php(560): Workerman\Worker::forkWorkers()
#22 phar:///Users/xiaoyinka/www/webman/build/webman.phar/vendor/workerman/webman-framework/src/support/App.php(131): Workerman\Worker::runAll()
#23 phar:///Users/xiaoyinka/www/webman/build/webman.phar/vendor/webman/console/src/Commands/StartCommand.php(29): support\App::run()
#24 phar:///Users/xiaoyinka/www/webman/build/webman.phar/vendor/symfony/console/Command/Command.php(298): Webman\Console\Commands\StartCommand->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#25 phar:///Users/xiaoyinka/www/webman/build/webman.phar/vendor/symfony/console/Application.php(1040): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#26 phar:///Users/xiaoyinka/www/webman/build/webman.phar/vendor/symfony/console/Application.php(301): Symfony\Component\Console\Application->doRunCommand(Object(Webman\Console\Commands\StartCommand), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#27 phar:///Users/xiaoyinka/www/webman/build/webman.phar/vendor/symfony/console/Application.php(171): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#28 phar:///Users/xiaoyinka/www/webman/build/webman.phar/webman(45): Symfony\Component\Console\Application->run()
#29 /Users/xiaoyinka/www/webman/build/webman.phar(5): require('phar:///Users/x...')
#30 {main} [] []
943 1 0
1个回答

walkor 打赏

把.env文件放在webman.phar所目录里
如果你希望.env打包进去,就把配置里'exclude_files' 里把 .env去掉

  • ss544325999 2023-03-20

    理解错文档意思了,以为exclude是包含的意思。

年代过于久远,无法发表回答
×
🔝