1

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...

1 Answer 1

2

Symfony uses composer, therefore you can autoload your class with composer autoload classmap or file: https://getcomposer.org/doc/04-schema.md#classmap

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.