开始开发框架的时候想使用php的自动加载函数来加载自定义的类,但是后来发现
哈哈,所以就使用composer重新代码重写了一下,顺便记录下在本地使用composer开发项目的步骤
首先新建一个composer扩展目录 /home/www/wwwroot/gdemo/hiframe/framework 并且创建 composer.json 文件,例如
{
"name": "hiframe/framework",
"require": {
"php": ">7.0"
},
"authors": [
{
"name": "gphper",
"email": "570165887@qq.com"
}
],
"autoload": {
"psr-4": {
"HiFrame\\Framework\\":"src"
},
"files": [
"src/Support/helpers.php"
]
}
}
然后在项目的根目录 /home/www/wwwroot/gdemo 新建composer.json定义内容如下
{
"name": "hiframe/hiframe",
"require": {
"hiframe/framework": "dev-master"
},
"repositories": {
"hiframe/framework": {
"type": "path",
"url": "/home/www/wwwroot/gdemo/hiframe/framework"
}
},
"autoload": {
"psr-4": {
"App\\": "app"
},
"files": [
"routes/api.php"
]
}
}
然后执行 composer install 实例化项目就好啦。
至于发布composer包的过程,可以参考下这篇 https://www.cnblogs.com/huaweichenai/p/10255439.html
扫码关注腾讯云开发者
领取腾讯云代金券
Copyright © 2013 - 2025 Tencent Cloud. All Rights Reserved. 腾讯云 版权所有
深圳市腾讯计算机系统有限公司 ICP备案/许可证号:粤B2-20090059 深公网安备号 44030502008569
腾讯云计算(北京)有限责任公司 京ICP证150476号 | 京ICP备11018762号 | 京公网安备号11010802020287
Copyright © 2013 - 2025 Tencent Cloud.
All Rights Reserved. 腾讯云 版权所有