How to automatically include a file, which is not a class, in the composer?

3

In composer, usually when we set up autoload for files containing classes, I usually do this:

"autoload" : { 
   "psr-4" : { "WallaceMaxters\Timer\" : 'src/timer'}
}

Composer will automatically load the file that has the same class name as it is instantiated.

But now I have a file called functions.php that has some functions that I want to include in that same library.

How do I make the composer automatically include a file?

    
asked by anonymous 15.01.2016 / 16:11

1 answer

1

You can also include arquivos in Composer:

{
    "autoload": {
        "files": ["src/minhaBiblioteca/functions.php"]
    }
}

In this way, Composer will ensure that files defined as files under the autoload directive will be loaded automatically.

Reference

15.01.2016 / 18:20