当前位置:网站首页>如何 Pr 一个开源composer项目
如何 Pr 一个开源composer项目
2022-07-29 05:19:00 【廖圣平】

看到一位朋友的 enum包,感觉还不错。
因为在实际开发中 我们使用 BenSampo/laravel-enum这个包去管理枚举。
在标准化项目中(比如国际化)其实这个包挺好的。但是在小项目中,先添加枚举类,再去enums.php 中添加翻译,让人感觉很烦~~~
像这样子:
所以对这个注解读取“翻译”的这个包,我很感兴趣。
但是问题来了,这个包里面只能读取枚举翻译,如果我需要一个数组呢?
像这样:
AppStatus::toSelectArray()
我想用这个包,但是我又想用到toArray,我满足这两个条件,我在小项目中就可以操刀就干,而又不失优雅。
所以,我决定fork一份自己改一下,添加toArray 的方法
fork好了之后,在项目根目录中添加 一个 packages的文件夹,在这个文件夹中,git clone https://github.com/liaoshengping/x-phalcon-enum
composer.json 中添加,本地目录
"repositories": [
{
"type": "path",
"url": "packages\\x-phalcon-enum",
"options": {
"versions": {
"limingxinleo/x-phalcon-enum": "dev-master"
}
}
}
]
接下来
composer require limingxinleo/x-phalcon-enum dev-master
在vendor 会生成一份 和packages 一样的 文件。这时已经映射到了 packages ,只需要修改其中的文件就可以了。
在 Enum.php 添加一个toArray 的静态方法。
public static function toArray(){
$ref = new ReflectionClass(static::class);
$properties = $ref->getDefaultProperties();
$_adapter = new ReflectionAdapter(static::class);
$arr = $_adapter->getAnnotationsByName('Message', $properties);
return $arr;
}
push 到 自己的master 上,创建一个 Pull Request,如图:

等大佬检查代码,如果通过则合并。
这样就完成了我第一个pr

边栏推荐
- Seay源代码审计系统
- Day 2
- ClickHouse学习(四)SQL操作
- Use QSS to style the form
- Using POI TL to insert multiple pictures and the same data of multiple rows of cells into the table cells of word template at one time, it is a functional component for automatic merging
- Three handshakes and four waves for the interview summary
- Clickhouse learning (XI) clickhouseapi operation
- 365 day challenge leetcode 1000 questions - day 035 one question per day + two point search 13
- C language n queen problem
- 解决表单校验提示信息不消失问题以及赋值不生效问题
猜你喜欢

Question swiping Madness - leetcode's sword finger offer58 - ii Detailed explanation of left rotation string

ClickHouse学习(五)集群操作
![[C language series] - constants and variables that confuse students](/img/24/1158034a5de413ea4ce160c5bfcbb4.png)
[C language series] - constants and variables that confuse students

【JS题解】牛客网JS篇1-10题
![[typescript] learn typescript object types in depth](/img/87/a9fd2f177331863e06fcf14559eeed.png)
[typescript] learn typescript object types in depth

Day 2

Flask 报错 RuntimeError: The session is unavailable because no secret key was set.

Clickhouse learning (x) monitoring operation indicators

DAY15(DAY16拓展):文件包含漏洞

Merge the same items in the same column in table
随机推荐
href与src的区别
Similarities and differences between REM and PX and EM
解决表单校验提示信息不消失问题以及赋值不生效问题
uniapp组件之tab选项卡滑动切换
Use QSS to style the form
Cmu15-213 shell lab experiment record
表格与表单相关知识点总结
JS simple code determines whether the device that opens the page is the PC end of the computer, the H5 end of the mobile phone, or the wechat end
实现table某个单元格背景色设置
WIN10 编译ffmpeg(包含ffplay)
ClickHouse学习(十)监控运行指标
[C language series] - print prime numbers between 100 and 200
Abstract classes and interfaces
Selection options of uniapp components (such as package selection)
Day 3
Clickhouse learning (IX) Clickhouse integrating MySQL
Wechat applet - component parameter transmission, state management
Hcia-r & s self use notes (26) PPP
Fvuln automated web vulnerability detection tool
table中同一列中合并相同项