美文网首页
解决Laravel中的mb_strimwidth()引起的问题。

解决Laravel中的mb_strimwidth()引起的问题。

作者: liurongming | 来源:发表于2024-01-18 14:46 被阅读0次
    • 问题:安装php artisan breeze:install时出现以下错误。
      Call to undefined function Termwind\ValueObjects\mb_strimwidth()
      问题就是:mb_strimwidth()不能识别,那么就解决宽字符问题,就能解决。
     php artisan breeze:install           
    
      Which Breeze stack would you like to install?
    
       Error 
    
      Call to undefined function Termwind\ValueObjects\mb_strimwidth()
    
      at vendor\nunomaduro\termwind\src\ValueObjects\Styles.php:1053
        1049▕      */
        1050▕     private static function trimText(string $text, int $width): string
        1051▕     {
        1052▕         preg_match_all(self::STYLING_REGEX, $text, $matches, PREG_OFFSET_CAPTURE);
      ➜ 1053▕         $text = rtrim(mb_strimwidth(preg_replace(self::STYLING_REGEX, '', $text) ?? '', 0, $width, '', 'UTF-8'));       
        1054▕
        1055▕         foreach ($matches[0] ?? [] as [$part, $index]) {
        1056▕             $text = substr($text, 0, $index).$part.substr($text, $index, null);
        1057▕         }
    
      1   vendor\nunomaduro\termwind\src\ValueObjects\Styles.php:870
          Termwind\ValueObjects\Styles::trimText("..................................................................................................................................")
    
      2   vendor\nunomaduro\termwind\src\ValueObjects\Styles.php:733
          Termwind\ValueObjects\Styles::applyWidth("..................................................................................................................................")
    
    
    • 查看一下版本:
    php --version
    PHP 8.3.1 (cli) (built: Dec 20 2023 14:06:10) (ZTS Visual C++ 2019 x64)
    Copyright (c) The PHP Group
    Zend Engine v4.3.1, Copyright (c) Zend Technologies
    
    • 因此解决:对应版本的php.ini中,添加:extension=php_mbstring.dll。支持宽字符串,问题就应该得到解决。参考配置如下:
    [Date]
    date.timezone=Asia/Shanghai
    [PHP]
    max_execution_time = 300
    max_input_time=60
    max_input_vars=3000
    memory_limit=256M
    upload_max_filesize = 100M
    post_max_size = 100M
    max_file_uploads = 100
    display_errors = On
    display_startup_errors=On
    log_errors=On
    track_errors=Off
    html_errors=On
    error_log=C:/phpstudy_pro/Extensions/php/php-8.3.1-Win32-vs16-x64.log
    error_reporting=E_ALL & ~E_NOTICE
    allow_url_fopen=On
    allow_url_include=Off
    extension_dir="C:\phpstudy_pro\Extensions\php\php-8.3.1-Win32-vs16-x64\ext"
    extension=php_pdo_mysql
    extension=php_openssl.dll
    extension=php_mbstring.dll
    extension=zip
    extension=curl
    variables_order = "GPCS"
    extension=php_fileinfo
    
    • 经过测试,加入extension=php_mbstring.dll后,再次执行结果如下:
     php artisan breeze:install
    
      Which Breeze stack would you like to install?
      Blade with Alpine ...................................................................................................... blade  
      Livewire (Volt Class API) with Alpine ............................................................................... livewire  
      Livewire (Volt Functional API) with Alpine ............................................................... livewire-functional  
      React with Inertia ..................................................................................................... react  
      Vue with Inertia ......................................................................................................... vue  
      API only ................................................................................................................. api  
    ❯ 
    

    至此,问题成功解决。

    相关文章

      网友评论

          本文标题:解决Laravel中的mb_strimwidth()引起的问题。

          本文链接:https://www.haomeiwen.com/subject/dptdodtx.html