46cl / wp-boilerplate

[unstable] A Wordpress boilerplate created by 46cl
MIT License
3 stars 1 forks source link

Remove automatic loading of all the files in the config directory #30

Closed nesk closed 6 years ago

nesk commented 9 years ago

This feature is, actually, a bad idea. It doesn't allow to order file loading and causes issues with FTP clients which doesn't automatically remove files when syncing the client and the server. Also, it forces you to put all the logic in the config directory, which is crappy for code organization.

Any thoughts about this @jvelo? We could move to a solution with a main file referencing all the files to load (autoload.php is a great name but it is already used by Composer, any ideas?):

return [
    'config/admin.php',
    'api/newsletter.php',
    'metaboxes/page.php',
];

This file is then required by functions.php and all the array entries are required through the require_once keyword.

jvelo commented 9 years ago

I don't know, I kind of liked it ; at least for configurations files.

I agree it's weird to have api/ under config/

nesk commented 9 years ago

After some consideration, we shouldn't create our own autoloading system but use the one provided by Composer (we done this for #10, we should continue on this way), resulting in this composer.json file:

{
    "autoload": {
        "files": [
            "config/admin.php",
            "api/newsletter.php",
            "metaboxes/page.php"
        ]
    }
}

However @jvelo, Composer doesn't seem to support autoloading for all the files in a directory :disappointed: