PECL PCSC 安装在 PHP 7.4

PECL PCSC install on PHP 7.4

我正在使用依赖包的 PHP 代码: https://pecl.php.net/package/pcsc

最后我需要从 PHP 5 更新到 PHP 7(够晚了)。不幸的是,CentOS 的 REMI 存储库不再支持 PHP7 的 PCSC,因此我尝试使用以下命令手动安装它:

pecl install channel://pecl.php.net/pcsc-0.3.1

但是我遇到了一堆错误(见下文)。有办法解决这个问题吗?在 PHP 中是否有访问智能卡的替代方法(未找到)?

错误:

/var/tmp/pcsc/pcsc.c:92:35: error: unknown type name 'zend_rsrc_list_entry' static void php_pcsc_ctx_res_dtor(zend_rsrc_list_entry *rsrc TSRMLS_DC) {

/var/tmp/pcsc/pcsc.c:113:36: error: unknown type name 'zend_rsrc_list_entry' static void php_pcsc_conn_res_dtor(zend_rsrc_list_entry *rsrc TSRMLS_DC) {

/var/tmp/pcsc/pcsc.c: In function 'zm_startup_pcsc': /var/tmp/pcsc/pcsc.c:272:53: error: 'php_pcsc_ctx_res_dtor' undeclared (first use in this function)
le_pcsc_ctx_res=zend_register_list_destructors_ex(php_pcsc_ctx_res_dtor, NULL, PHP_PCSC_CTX_RES_NAME,module_number);

/var/tmp/pcsc/pcsc.c:272:53: note: each undeclared identifier is reported only once for each function it appears in /var/tmp/pcsc/pcsc.c:273:54: error: 'php_pcsc_conn_res_dtor' undeclared (first use in this function)
le_pcsc_conn_res=zend_register_list_destructors_ex(php_pcsc_conn_res_dtor, NULL, PHP_PCSC_CONN_RES_NAME,module_number);

/var/tmp/pcsc/pcsc.c: In function 'zif_scard_is_valid_context': /var/tmp/pcsc/pcsc.c:521:31: error: expected expression before 'SCARDCONTEXT'
ZEND_FETCH_RESOURCE(context,SCARDCONTEXT,&ctx_res,-1,PHP_PCSC_CTX_RES_NAME,le_pcsc_ctx_res);

/var/tmp/pcsc/pcsc.c: In function 'zif_scard_release_context': /var/tmp/pcsc/pcsc.c:543:31: error: expected expression before 'SCARDCONTEXT'
ZEND_FETCH_RESOURCE(context,SCARDCONTEXT,&ctx_res,-1,PHP_PCSC_CTX_RES_NAME,le_pcsc_ctx_res);

/var/tmp/pcsc/pcsc.c: In function 'zif_scard_list_readers': /var/tmp/pcsc/pcsc.c:564:31: error: expected expression before 'SCARDCONTEXT'
ZEND_FETCH_RESOURCE(context,SCARDCONTEXT,&ctx_res,-1,PHP_PCSC_CTX_RES_NAME,le_pcsc_ctx_res);

/var/tmp/pcsc/pcsc.c:580:5: error: too many arguments to function 'add_next_index_string' add_next_index_string(return_value, ptrReader, TRUE);

In file included from /usr/include/php/main/php.h:37:0, from /var/tmp/pcsc/pcsc.c:23: /usr/include/php/Zend/zend_API.h:432:14: note: declared here ZEND_API int add_next_index_string(zval *arg, const char *str);

/var/tmp/pcsc/pcsc.c: In function 'zif_scard_connect': /var/tmp/pcsc/pcsc.c:609:31: error: expected expression before 'SCARDCONTEXT'
ZEND_FETCH_RESOURCE(context,SCARDCONTEXT,&ctx_res,-1,PHP_PCSC_CTX_RES_NAME,le_pcsc_ctx_res);

/var/tmp/pcsc/pcsc.c: In function 'zif_scard_disconnect': /var/tmp/pcsc/pcsc.c:634:29: error: expected expression before 'SCARDHANDLE'
ZEND_FETCH_RESOURCE(hCard,SCARDHANDLE,&conn_res,-1,PHP_PCSC_CONN_RES_NAME,le_pcsc_conn_res);

/var/tmp/pcsc/pcsc.c: In function 'zif_scard_transmit': /var/tmp/pcsc/pcsc.c:665:29: error: expected expression before 'SCARDHANDLE'
ZEND_FETCH_RESOURCE(hCard,SCARDHANDLE,&conn_res,-1,PHP_PCSC_CONN_RES_NAME,le_pcsc_conn_res);

/var/tmp/pcsc/pcsc.c:708:58: error: macro "RETVAL_STRING" passed 2 arguments, but takes just 1
RETVAL_STRING(e_bytes_to_hex(recvBuffer, recvLen), TRUE);

/var/tmp/pcsc/pcsc.c:708:3: error: 'RETVAL_STRING' undeclared (first use in this function) RETVAL_STRING(e_bytes_to_hex(recvBuffer, recvLen), TRUE);

/var/tmp/pcsc/pcsc.c: In function 'zif_scard_status': /var/tmp/pcsc/pcsc.c:731:29: error: expected expression before 'SCARDHANDLE'
ZEND_FETCH_RESOURCE(hCard,SCARDHANDLE,&conn_res,-1,PHP_PCSC_CONN_RES_NAME,le_pcsc_conn_res);

/var/tmp/pcsc/pcsc.c:763:85: error: macro "add_assoc_string" passed 4 arguments, but takes just 3 add_assoc_string(return_value, "PROTOCOL", "RAW", TRUE);

/var/tmp/pcsc/pcsc.c:763:31: error: 'add_assoc_string' undeclared (first use in this function) add_assoc_string(return_value, "PROTOCOL", "RAW", TRUE);

/var/tmp/pcsc/pcsc.c:766:85: error: macro "add_assoc_string" passed 4 arguments, but takes just 3 add_assoc_string(return_value, "PROTOCOL", "T=0", TRUE);

/var/tmp/pcsc/pcsc.c:769:85: error: macro "add_assoc_string" passed 4 arguments, but takes just 3 add_assoc_string(return_value, "PROTOCOL", "T=1", TRUE);

/var/tmp/pcsc/pcsc.c:777:58: error: macro "add_assoc_string" passed 4 arguments, but takes just 3 add_assoc_string(return_value, "ATR", atrString, TRUE);

/var/tmp/pcsc/pcsc.c: In function 'zif_scard_errstr': /var/tmp/pcsc/pcsc.c:799:53: error: macro "RETURN_STRING" passed 2 arguments, but takes just 1
RETURN_STRING(php_pcsc_error_to_string(in_errno),1);

/var/tmp/pcsc/pcsc.c:799:3: error: 'RETURN_STRING' undeclared (first use in this function)
RETURN_STRING(php_pcsc_error_to_string(in_errno),1);

make: *** [pcsc.lo] Fehler 1 ERROR: `make' failed

Finally I need to update from PHP 5 to PHP 7 (late enough). The REMI repo for CentOS unfortunately does not support PCSC for PHP7 anymore so I tried to install it manually by using the command:

如果扩展兼容,它将在存储库中,因为所有 other extensions

所以这看起来是一个死项目。

我是这个扩展的开发者,几周前它是最新的。

只需使用以下命令安装它:

pecl install pcsc-beta

您也可以从https://github.com/pcsc-for-php/pcsc获取代码并自行编译。您可以在 GitHub 页面上找到说明。