psr-4如何加载没有类/命名空间的文件

I have a bunch of php files

each file contains one function

no class

no namespace

just global functions.

How can I load those files easily with composer? with psr-4 autoloader or any similar option so I don't have to require() all the time all files

Composer has support for autoloading functions. The only caveat is the functions are always included, they aren't loaded on demand.

{
    "autoload": {
        "files": ["src/MyLibrary/functions.php", "foo/bar/baz.php"]
    }
}

https://getcomposer.org/doc/04-schema.md#files