swoole / swoole-src

🚀 Coroutine-based concurrency library for PHP
https://www.swoole.com
Apache License 2.0
18.41k stars 3.16k forks source link

手动新增mailparse扩展不成功 #5381

Closed julibo closed 2 months ago

julibo commented 2 months ago
  1. 我在sapi/src/builder/extension下新建了一个mailparse.php
<?php

use SwooleCli\Preprocessor;
use SwooleCli\Extension;

return function (Preprocessor $p) {
    $p->addExtension(
        (new Extension('mailparse'))
            ->withHomePage('https://pecl.php.net/package/mailparse')
            ->withLicense('https://github.com/php/pecl-mail-mailparse/blob/v3.1.6/LICENSE', Extension::LICENSE_BSD)
            ->withManual('https://github.com/php/pecl-mail-mailparse.git')
            ->withPeclVersion('3.1.6')
            ->withOptions(' --with-mailparse ')
            ->withDependentExtensions('mbstring')
    );
};
  1. 在linux下依次执行以下代码
    
    bash setup-php-runtime.sh
    composer install  --no-interaction --no-autoloader --no-scripts --profile
    composer dump-autoload --optimize --profile

php prepare.php +mailparse

输出部分结果如下所示,已经包含了mailparse

========================================================== Extension count: 41

opcache curl iconv bz2 bcmath pcntl filter session tokenizer mbstring ctype zlib zip posix sockets pdo sqlite3 phar mysqlnd mysqli intl fileinfo pdo_mysql soap xsl gmp exif sodium openssl readline xml redis swoole yaml imagick mongodb gd mailparse xlswriter ssh2 uuid


3. 继续执行下面的脚本

bash ./make.sh docker-build bash ./make.sh docker-bash

bash sapi/quickstart/linux/alpine-init.sh

进入容器后需要再一次执行此命令

php prepare.php +mailparse bash ./make.sh all-library bash ./make.sh config bash ./make.sh build bash ./make.sh archive


4. 最终打包的swoole-cli并不包含 mailparse
jingjingxyk commented 2 months ago

@julibo 问题所在: ->withOptions(' --with-mailparse ') 改成 ->withOptions(' --enable-mailparse ') 即可。 配置文件详情看这里: https://github.com/php/pecl-mail-mailparse/blob/master/config.m4#L2C4-L2C22

jingjingxyk commented 2 months ago

image

使用实验分支(experiment),可以快速验证(只编译 mailparse swoole 两个扩展)

php prepare.php +mailparse +swoole --with-http-proxy=socks5h://172.23.24.221:8010

jingjingxyk commented 2 months ago

<?php

use SwooleCli\Preprocessor;
use SwooleCli\Extension;

return function (Preprocessor $p) {
    $p->addExtension(
        (new Extension('mailparse'))
            ->withHomePage('https://pecl.php.net/package/mailparse')
            ->withLicense('https://github.com/php/pecl-mail-mailparse/blob/v3.1.6/LICENSE', Extension::LICENSE_BSD)
            ->withManual('https://github.com/php/pecl-mail-mailparse.git')
            ->withPeclVersion('3.1.6')
            ->withOptions(' --enable-mailparse ')
            ->withDependentExtensions('mbstring')
    );
};