使用webman-admin 打包二进制,用二进制文件运行后报错,源码不会

isle

问题描述

使用webman-admin 打包二进制,用二进制文件运行后报错,源码不会。

程序代码

    /**
     * Determine if a given offset exists.
     *
     * @param  string  $key
     * @return bool
     */
    public function offsetExists($key)
    {
        return $this->bound($key);
    }

报错信息

2023-06-29 10:57:56 pid:29062 Worker[29062] process terminated with ERROR: E_ERROR "During inheritance of ArrayAccess: Uncaught ErrorException: Return type of Illuminate\Container\Container::offsetExists($key) should either be compatible with ArrayAccess::offsetExists(mixed $offset): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in phar:///home/www/webman/build/webman.bin/vendor/illuminate/container/Container.php:1270
Stack trace:
#0 phar:///home/www/webman/build/webman.bin/vendor/illuminate/container/Container.php(15): support\App::{closure}(8192, 'Return type of ...', 'phar:///home/ww...', 1270)
#1 phar:///home/www/webman/build/webman.bin/vendor/composer/ClassLoader.php(478): include('phar:///home/ww...')
#2 phar:///home/www/webman/build/webman.bin/vendor/composer/ClassLoader.php(346): Composer\Autoload\includeFile('phar:///home/ww...')
#3 phar:///home/www/webman/build/webman.bin/vendor/workerman/webman-framework/src/support/bootstrap/LaravelDb.php(54): Composer\Autoload\ClassLoader->loadClass('Illuminate\\Cont...')
#4 phar:///home/www/webman/build/webman.bin/support/bootstrap.php(93): support\bootstrap\LaravelDb::start(Object(Workerman\Worker))
#5 phar:///home/www/webman/build/webman.bin/vendor/workerman/webman-framework/src/support/App.php(104): require_once('phar:///home/ww...')
#6 phar:///home/www/webman/build/webman.bin/vendor/workerman/workerman/Worker.php(2488): support\App::support\{closure}(Object(Workerman\Worker))
#7 phar:///home/www/webman/build/webman.bin/vendor/workerman/workerman/Worker.php(1627): Workerman\Worker->run()
#8 phar:///home/www/webman/build/webman.bin/vendor/workerman/workerman/Worker.php(1423): Workerman\Worker::forkOneWorkerForLinux(Object(Workerman\Worker))
#9 phar:///home/www/webman/build/webman.bin/vendor/workerman/workerman/Worker.php(1397): Workerman\Worker::forkWorkersForLinux()
#10 phar:///home/www/webman/build/webman.bin/vendor/workerman/workerman/Worker.php(560): Workerman\Worker::forkWorkers()
#11 phar:///home/www/webman/build/webman.bin/vendor/workerman/webman-framework/src/support/App.php(131): Workerman\Worker::runAll()
#12 phar:///home/www/webman/build/webman.bin/vendor/webman/console/src/Commands/StartCommand.php(29): support\App::run()
#13 phar:///home/www/webman/build/webman.bin/vendor/symfony/console/Command/Command.php(298): Webman\Console\Commands\StartCommand->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#14 phar:///home/www/webman/build/webman.bin/vendor/symfony/console/Application.php(1040): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#15 phar:///home/www/webman/build/webman.bin/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))
#16 phar:///home/www/webman/build/webman.bin/vendor/symfony/console/Application.php(171): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#17 phar:///home/www/webman/build/webman.bin/webman(45): Symfony\Component\Console\Application->run()
#18 /home/www/webman/build/webman.bin(5): require('phar:///home/ww...')
#19 {main} in phar:///home/www/webman/build/webman.bin/vendor/illuminate/container/Container.php on line 15"

操作系统及workerman/webman等框架组件具体版本

Workerman版本 4.1.10
Webman版本 1.5.6
WebmanAdmin版本 0.6.13
PHP版本 7.2.33
MYSQL版本 5.6.50-log
操作系统 Linux

980 1 0
1个回答

yongdao35

你本地是php7.2,打包是php8.x,8.x有更严格的验证,所以报错了。
打包时本地版本和打包版本要一致才能保证不出错。手册也说要版本一致才能不出兼容问题。

  • isle 2023-06-29

    我本地是7.2,打包也是7.2,但是应该是 使用的8.1的文件(官方文档有写),然后我下载了官方的8的文件,直接用8的文件composer之后打包,OK了

  • isle 2023-06-29

    我之前是这样打包的:php -d phar.readonly=0 webman build:bin 7.2
    指定了打包7.2,但是实际使用的是8.1,所以报错了

  • isle 2023-06-29

    已解决,下载了官方的php8的文件,直接用8的文件composer之后打包,OK了
    先更新composer:/www/wwwroot/php /usr/bin/composer update
    再打包:/www/wwwroot/php -d phar.readonly=0 webman build:bin 8.1
    执行打包后的文件,正常

  • yongdao35 2023-06-29

    嗯,文档说只能打包成php8的二进制文件,指定7.2没用

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