PHP namespace - solution for including all classes in a namespace

Is there a solution to include all classes separately in the namespace?

My Laravel files are getting huge because I have to continue to include loading namespaces ... It's pretty awful!

As a workaround, why not work:

namespace.Blah.txt:

use Blah\Blah; use Blah\Bloh; 

php code:

 eval( file_get_contents( "namespace.Blah.txt" ); 

If I could make it work, I could appreciate the contents of the file ... I understand its a bit noob ... but ... damn it!

+5
source share
1 answer

No, but in PHP 7 you can

 use FooLibrary\Bar\Baz\{ ClassA, ClassB, ClassC, ClassD as Fizbo }; 

How did the next RFC go:

https://wiki.php.net/rfc/group_use_declarations

EDIT:

Note that too many uses in the classroom may be a sign of β€œsmell.” Doesn't this particular class do too much? Shouldn't you create new β€œbase” classes and extend them?

+7
source

All Articles