-
-
Notifications
You must be signed in to change notification settings - Fork 4.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support Autoloading Functions and Constants #6232
Comments
Out of pure curiosity, why would you do this? Moving to classes will help with your own sanity as the project expands. |
You might be right. This is an experiment. eventually I would like to see how to implement functional programming in to PHP and seamlessly be part of the php community with composer. I know the sample project I have is not really "functional" right now, but composer supporting autoloaded functions with namespaces will be a huge leap forward. It follows the same general namespacing rules as the PSR4 for classes, so its not intrusive to existing codebases. |
PHP itself offers no autoloading of functions/constants, so until it does we can't really support that at all. Wrapping in classes definitely is easier, even though it feels a bit silly/redundant that the language makes us do that. |
this lack of autoloading function files is imposing Object Oriented mupitz on all of us. A function is a function and NOT! a class. It really is a sympthon of bad education of all these people who think putting pure stateless functions in a class is in any way a good idea. It totally sucks, and degrades software quality imposing OO mumpitz in places where it doesnt belong. |
Composer has "file autoloading" that is used for functions and constants. Example with Symfony polyfills |
no, it does not. It has the "files" feature to autoload PHP files. But neither declaration of the function: use My\Namespace\Functions\foo; nor its usage: foo(1,2,3); will trigger the autoloading of the file containing the function. Explicitly pre-loading all files is quite different from autoloading files on demand. |
Please direct your php language feature requests/rants to the appropriate channels. There's nothing we can do about this here. |
Sorry when I was hurting your or anyone's feelings, but rejecting false statements is okay in a technical discussion?
|
I would also like to see this feature. |
I have this composer package https://github.com/PabloJoan/slack-delete
I do not use any classes to write code. Only functions. I organize my code by putting 1 function in 1 file, organizing these files in folders, and then name space them. Basically following everything in PSR-4 except instead of a Class with namespace, its a Function with namespace.
there is no autoloading feature in composer to support this.
I've had to resort to using "files" to get this to work https://getcomposer.org/doc/04-schema.md#files .
The issue is that I have to manually add all these files and it can get very lengthy.
See below.
My
composer.json
:How would you suggest I manage this better?
The text was updated successfully, but these errors were encountered: