Reputation: 293
So we've got lots of legacy code we'd like to be able to use it in a new project we're working on which is to be written using symfony. We have lots of classes which aren't named spaced which reference other classes and such. Is there a way to autoload all of our classes without having to change all of them to live under a namespace? Ideally we won't have to change any code in our classes we can just load them as we do now. Each class is in a separate file named the same as the class, all the classes live in the same folder.
So we've got classes that look like:
// Foo.php
Class Foo {
public function bar() {
$baz = new Baz();
}
}
Is there a way to load them in so they can be used as is? Don't fancy going around and adding namespaces everywhere the classes are used...
Upvotes: 1
Views: 852
Reputation: 1893
Symfony uses composer, therefore you can autoload your class with composer autoload classmap or file: https://getcomposer.org/doc/04-schema.md#classmap
Upvotes: 2