https://github.com/minbaby/php-ext-startup
php-ext-startup php-extension startup
https://github.com/minbaby/php-ext-startup
extension kahlan php startup
Last synced: about 1 year ago
JSON representation
php-ext-startup php-extension startup
- Host: GitHub
- URL: https://github.com/minbaby/php-ext-startup
- Owner: minbaby
- License: mit
- Created: 2018-11-07T08:43:45.000Z (over 7 years ago)
- Default Branch: feature/stringy
- Last Pushed: 2020-12-16T10:36:16.000Z (over 5 years ago)
- Last Synced: 2025-06-05T10:50:36.269Z (about 1 year ago)
- Topics: extension, kahlan, php, startup
- Language: C
- Homepage: https://minbaby.github.io
- Size: 288 KB
- Stars: 5
- Watchers: 2
- Forks: 3
- Open Issues: 3
-
Metadata Files:
- Readme: README.MD
- License: LICENSE
Awesome Lists containing this project
README
# 学习 php 扩展
[](https://circleci.com/gh/minbaby/php-ext-startup/tree/master)
[](https://github.com/minbaby/php-ext-startup/blob/master/README.MD)
[](https://codecov.io/gh/minbaby/php-ext-startup)
## 基本思路
1. 先写测试用例
2. 再用 php 实现
3. 再用 ext 实现
4. 跑测试
## 测试思路
利用 php [自动加载](http://www.php.net/manual/zh/language.oop5.autoload.php)的逻辑。
1. ~~默认禁用扩展执行一遍测试,这个时候执行的是 PHP 逻辑~~
2. ~~启用扩展再执行一次扩展, 这个时候执行的是 EXT 逻辑 (这个地方有个问题,如果 ext 扩展不存在,那么就会降级使用 php 代码)~~
使用函数动态生成对应的带有命名空间的类名,原因是之前的思路存在漏洞,因为自动加载的存在,导致如果 ext 中不存在,就会自动降级为 php 代码。
## 学习方式
如果我们需要查看这个项目,那么思路是什么的?
1. 先看 `spec/` 这些文件的测试用例。
2. 查看 `src/Minbaby/` 目录下的 php 实现
3. 查看 `src/ext` 目录下的 c 实现
## 常用命令
1. 测试所有
```bash
composer run test
# or
make ext-first
```
2. 测试 php 部分代码
```bash
composer run test-php
# or
make ext-test
```
3. 测试 ext 部分代码
```bash
composer run test-ext
# or
make ext-test-ext
```
4. 其他命令
```bash
make ext-clean # clean code
make ext-fetch # fetch configure ext code from github
make ext-prepare # phpize & configure
make ext-buidl
```
## TODO
- [ ] [stringy](https://github.com/danielstjules/Stringy)
## 说明
- 本项目只是学习实践使用
- 使用 `@` 抑制符不是一个好习惯,尽量不要使用。
- 依赖 `mb_string` 扩展
## 已知问题
- 0.0 很多
- memory leak (可能使用改方案来排查 https://github.com/arnaud-lb/php-memory-profiler)
### skip ci
- `[skip ci]`
- `[ci skip]`
### 参考
- [phpbook](https://github.com/walu/phpbook)
- [Kahlan](https://kahlan.github.io/docs/index.html)