composer有四种自动加载形式
file,classmap,psr-0,psr-4
第一种file 是最简单的
目录下的文件
文件的内容
index.php
我的composer.json配置
{
"name": "taoshihan/composer",
"autoload": {
"files":["helper.php"]
},
"authors": [
{
"name": "taoshihan",
"email": "taoshihan@xiavan.com"
}
],
"require": {}
}
注意执行
composer dump-autoload
生成一下映射关系 vendor/composer/autoload_files.php就会生成映射数组
这个时候在index.php中就可以直接使用helper.php文件中的内容了
扫码关注腾讯云开发者
领取腾讯云代金券
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. 腾讯云 版权所有