fatfree-core icon indicating copy to clipboard operation
fatfree-core copied to clipboard

Autoload: try convert camel / pascal to snake case for files name.

Open RoverWire opened this issue 2 years ago • 2 comments

In the current version if you name your clases for example like ApiController the autoload look for a file called apicontroller.php or ApiController.php but not for api_controller.php.

I think, since file and class naming are part of good code practices, F3 should add this case prior to ease some class naming convention instead to force to think to the file name first.

Thoughts?

RoverWire avatar Apr 16 '22 19:04 RoverWire

F3 is just a kick-off for the most cases and considering most ppl somehow follow PSR-4, I'd tend to say that your case is not that common :) Nevertheless, as far as I understand when taking a look into the autoload-function, setting the AUTOLOAD-var properly allows you to add a function to transform the classname for your needs. If this still does not cover your needs, there is spl_autoload_register as the last resort.

KOTRET avatar Apr 19 '22 06:04 KOTRET

I see, I would like F3 have this out of the box, for people using another frameworks like CodeIgniter, Laravel (or Rails) this is a common behavior.

UPDATE: I saw the reference on PSR-4 and you're right. I gonna close the PR.

RoverWire avatar Apr 19 '22 13:04 RoverWire