diff --git a/include/source.h b/include/source.h index 782ab46..81097d1 100644 --- a/include/source.h +++ b/include/source.h @@ -127,19 +127,6 @@ typedef struct { static SourceInfo -/** - * @time 2024-04-18 更新 - * @note 缺少教育网或开源社区软件源 - */ -pl_php_sources[] = { - {&Upstream, NULL}, - {&Ali, "https://mirrors.aliyun.com/composer/"}, - {&Tencent, "https://mirrors.tencent.com/composer/"}, - {&Huawei, "https://mirrors.huaweicloud.com/repository/php/"} -}, - - - /** * @time 2024-05-24 更新 * @note 以下都支持稀疏索引,我们换源时都将默认添加 `sparse+` @@ -770,7 +757,6 @@ wr_tex_sources[] = { #define def_sources_n(t) const size_t t##_sources_n = xy_arylen(t##_sources) -def_sources_n(pl_php); def_sources_n(pl_rust); def_sources_n(pl_java); def_sources_n(pl_clojure); def_sources_n(pl_dotnet); def_sources_n(pl_dart); def_sources_n(pl_haskell); diff --git a/src/chsrc.c b/src/chsrc.c index ff06abb..9b51b83 100644 --- a/src/chsrc.c +++ b/src/chsrc.c @@ -26,48 +26,7 @@ #include "recipe/lang/python.c" #include "recipe/lang/nodejs.c" #include "recipe/lang/perl.c" - - -void -pl_php_check_cmd () -{ - chsrc_ensure_program ("composer"); -} - -/** - * 已在Windows上测试通过,待其他平台PHP用户确认 - */ -void -pl_php_getsrc (char *option) -{ - pl_php_check_cmd (); - chsrc_run ("composer config -g repositories", RunOpt_Default); -} - -/** - * PHP 换源,参考:https://developer.aliyun.com/composer - */ -void -pl_php_setsrc (char *option) -{ - pl_php_check_cmd (); - - SourceInfo source; - chsrc_yield_source (pl_php); - chsrc_confirm_source (&source); - - char *where = " -g "; - if (CliOpt_Locally==true) - { - where = " "; - } - - char *cmd = xy_strjoin (4, "composer config", where, "repo.packagist composer ", source.url); - chsrc_run (cmd, RunOpt_Default); - - chsrc_say_lastly (&source, ChsrcTypeSemiAuto); -} - +#include "recipe/lang/php.c" #include "recipe/lang/lua.c" #include "recipe/lang/go.c" @@ -1932,7 +1891,6 @@ wr_anaconda_setsrc (char *option) /************************************** Begin Target Matrix ****************************************/ -def_target(pl_php); def_target(pl_rust); def_target(pl_java); def_target(pl_dart); def_target(pl_ocaml); def_target(pl_r); def_target(pl_julia); def_target_noget (pl_clojure); diff --git a/src/recipe/lang/php.c b/src/recipe/lang/php.c new file mode 100644 index 0000000..c14242e --- /dev/null +++ b/src/recipe/lang/php.c @@ -0,0 +1,63 @@ +/** ------------------------------------------------------------ + * SPDX-License-Identifier: GPL-3.0-or-later + * ------------------------------------------------------------- + * Contributors : Aoran Zeng + * Created on : <2023-09-06> + * Last modified : <2024-08-09> + * ------------------------------------------------------------*/ + +/** + * @time 2024-04-18 更新 + * @note 缺少教育网或开源社区软件源 + */ +static SourceInfo +pl_php_sources[] = { + {&Upstream, NULL}, + {&Ali, "https://mirrors.aliyun.com/composer/"}, + {&Tencent, "https://mirrors.tencent.com/composer/"}, + {&Huawei, "https://mirrors.huaweicloud.com/repository/php/"} +}; +def_sources_n(pl_php); + + +void +pl_php_check_cmd () +{ + chsrc_ensure_program ("composer"); +} + +/** + * 已在Windows上测试通过,待其他平台PHP用户确认 + */ +void +pl_php_getsrc (char *option) +{ + pl_php_check_cmd (); + chsrc_run ("composer config -g repositories", RunOpt_Default); +} + +/** + * PHP 换源,参考:https://developer.aliyun.com/composer + */ +void +pl_php_setsrc (char *option) +{ + pl_php_check_cmd (); + + SourceInfo source; + chsrc_yield_source (pl_php); + chsrc_confirm_source (&source); + + char *where = " -g "; + if (CliOpt_Locally==true) + { + where = " "; + } + + char *cmd = xy_strjoin (4, "composer config", where, "repo.packagist composer ", source.url); + chsrc_run (cmd, RunOpt_Default); + + chsrc_say_lastly (&source, ChsrcTypeSemiAuto); +} + +def_target(pl_php);