打包后運行出現(xiàn)如上報錯
配置文件 修改成以下:
return [
'enable' => true,
'phar_file_output_dir' => BASE_PATH . DIRECTORY_SEPARATOR . 'build',
'phar_filename' => 'webman.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'
]*/
'exclude_pattern' => null,
'exclude_files' => [],
];
修改之后報另個錯誤了。
TypeError: Return value of exception\Handler::render() must be an instance of Webman\Http\Response, instance of Workerman\Protocols\Http\Response returned in phar:///www/local.lis.com/build/webman.phar/exception/Handler.php:74 Stack trace: #0 phar:///www/local.lis.com/build/webman.phar/vendor/workerman/webman-framework/src/App.php(215): exception\Handler->render(Object(support\Request), Object(TypeError)) #1 phar:///www/local.lis.com/build/webman.phar/vendor/workerman/webman-framework/src/App.php(166): Webman\App::exceptionResponse(Object(TypeError), Object(support\Request)) #2 phar:///www/local.lis.com/build/webman.phar/vendor/workerman/workerman/Connection/TcpConnection.php(638): Webman\App->onMessage(Object(Workerman\Connection\TcpConnection), Object(support\Request)) #3 phar:///www/local.lis.com/build/webman.phar/vendor/workerman/workerman/Events/Select.php(295): Workerman\Connection\TcpConnection->baseRead(Resource id #538) #4 phar:///www/local.lis.com/build/webman.phar/vendor/workerman/workerman/Worker.php(2431): Workerman\Events\Select->loop() #5 phar:///www/local.lis.com/build/webman.phar/vendor/workerman/workerman/Worker.php(1555): Workerman\Worker->run() #6 phar:///www/local.lis.com/build/webman.phar/vendor/workerman/workerman/Worker.php(1397): Workerman\Worker::forkOneWorkerForLinux(Object(Workerman\Worker)) #7 phar:///www/local.lis.com/build/webman.phar/vendor/workerman/workerman/Worker.php(1371): Workerman\Worker::forkWorkersForLinux() #8 phar:///www/local.lis.com/build/webman.phar/vendor/workerman/workerman/Worker.php(549): Workerman\Worker::forkWorkers() #9 phar:///www/local.lis.com/build/webman.phar/vendor/webman/console/src/Application.php(109): Workerman\Worker::runAll() #10 phar:///www/local.lis.com/build/webman.phar/vendor/webman/console/src/Commands/StartCommand.php(28): Webman\Console\Application::run() #11 phar:///www/local.lis.com/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)) #12 phar:///www/local.lis.com/build/webman.phar/vendor/symfony/console/Application.php(1015): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput)) #13 phar:///www/local.lis.com/build/webman.phar/vendor/symfony/console/Application.php(299): Symfony\Component\Console\Application->doRunCommand(Object(Webman\Console\Commands\StartCommand), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput)) #14 phar:///www/local.lis.com/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)) #15 phar:///www/local.lis.com/build/webman.phar/webman(30): Symfony\Component\Console\Application->run() #16 /www/local.lis.com/build/webman.phar(5): require('phar:///www/loc...') #17 {main}
報錯說的很明確了,你的exception/Handler.php
文件里exception\Handler::render()
方法應該返回一個Webman\Http\Response
對象,但是你返回了Workerman\Protocols\Http\Response
。
打包后的驗證碼不能用提示打不開字體我看了字體文件也是有的。權限也給了最高權限
phar:///www/local.lis.com/build/webman.phar/vendor/gregwar/captcha/src/Gregwar/Captcha/CaptchaBuilder.php
345
imagettfbbox(): Could not find/open font
[已解決]在驗證碼庫里通過__DIR__讀取的字體目錄打包后要把字體文件移到build下修改__DIR__的讀取方式
if ($font === null) {
$realPath = \Phar::running() ? pathinfo(\Phar::running(false), PATHINFO_DIRNAME).'/Font':__DIR__.'/Font';
$font = $realPath . '/captcha'.$this->rand(0, 5).'.ttf';
}