首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >关于php创建扩展的一个坑:找不到skeleton

关于php创建扩展的一个坑:找不到skeleton

作者头像
仙士可
发布2019-12-19 14:39:40
1.1K0
发布2019-12-19 14:39:40
举报
文章被收录于专栏:仙士可博客仙士可博客

在前几天,我突然想研究树莓派的php io扩展,然后开始看自己之前的扩展开发教程:http://www.php20.cn/article/sw/%E6%89%A9%E5%B1%95/177

随便下载了一个php7.1的版本,cd 进入ext文件:

pi@raspberrypi:~/php-src-php-7.1.29 $ cd ext/
pi@raspberrypi:~/php-src-php-7.1.29/ext $ ls
bcmath    com_dotnet  date  enchant   ext_skel_win32.php  ftp      gmp    imap       json    mbstring
bz2       ctype       dba   exif      fileinfo            gd       hash   interbase  ldap
calendar  curl        dom   ext_skel  filter              gettext  iconv  intl       libxml
pi@raspberrypi:~/php-src-php-7.1.29/ext $

才发现,原来只有php7.3的某一个版本,才是用的 ext_skel.php   文件生成,在之前的版本,都是shell

其实都差不多啦,然后我开始了正常的生成操作:

pi@raspberrypi:~/php-src-php-7.1.29/ext $ ./ext_skel --extname=phpPi
./ext_skel: 1: cd: can't cd to skeleton
Creating directory phpPi
Creating basic files: config.m4 config.w32 .gitignore phpPi.c./ext_skel: 247: ./ext_skel: cannot open /skeleton.c: No such file
 php_phpPi.h./ext_skel: 265: ./ext_skel: cannot open /php_skeleton.h: No such file
 CREDITS./ext_skel: 269: ./ext_skel: cannot open /CREDITS: No such file
 EXPERIMENTAL./ext_skel: 273: ./ext_skel: cannot open /EXPERIMENTAL: No such file
 tests/001.phpt./ext_skel: 278: ./ext_skel: cannot open /tests/001.phpt: No such file
 phpPi.php./ext_skel: 282: ./ext_skel: cannot open /skeleton.php: No such file
 [done].

To use your new extension, you will have to execute the following steps:

1.  $ cd ..
2.  $ vi ext/phpPi/config.m4
3.  $ ./buildconf
4.  $ ./configure --[with|enable]-phpPi
5.  $ make
6.  $ ./sapi/cli/php -f ext/phpPi/phpPi.php
7.  $ vi ext/phpPi/phpPi.c
8.  $ make

Repeat steps 3-6 until you are satisfied with ext/phpPi/config.m4 and
step 6 confirms that your module is compiled into PHP. Then, start writing
code and repeat the last two steps as often as necessary.

pi@raspberrypi:~/php-src-php-7.1.29/ext $

./ext_skel: 1: cd: can't cd to skeleton 错误是什么鬼???

百度了一晚上,一直没找到原因,后来我换成了php7.3版本

pi@raspberrypi:~/php-src-php-7.3.3/ext $ php ext_skel.php 
Error: No extension name passed, use "--ext <name>"
pi@raspberrypi:~/php-src-php-7.3.3/ext $ php ext_skel.php --ext phpPi
Error: The skeleton directory was not found
pi@raspberrypi:~/php-src-php-7.3.3/ext $

同样报错

Error: The skeleton directory was not found

那 skeleton是什么呢?

我查了很久很久,后来才发现,在php-src源码中,是有skeleton这个目录的,在ext目录下,还有着很多很多的扩展,而我解压的文件却没有显示:

很明显,我下载的文件有问题,我用的是wget方式下载,后来我登录其他服务器,使用其他服务器下载下来,才发现了区别:

很明显了,下载的时候,可能因为网络问题,导致文件缺失。并且解压的时候有提示,只是我那时候根本不知道:

gzip: stdin: unexpected end of file

tar: 归档文件中异常的 EOF

tar: 归档文件中异常的 EOF

tar: Error is not recoverable: exiting now

这下终于找到了原因,通过解压完整版,开始生成扩展:

成功生成扩展文件,可以愉快的写代码了

本文为仙士可原创文章,转载无需和我联系,但请注明来自仙士可博客www.php20.cn

本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2019-07-06 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档