在前几天,我突然想研究树莓派的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
这下终于找到了原因,通过解压完整版,开始生成扩展:
成功生成扩展文件,可以愉快的写代码了