0

I am using Symfonys Autoloader for a project having the following folder/class structure:

App
+- Package1
|
+- Package2
  +- Class1.php
|
- Interface1.php

How do i implement a class from a parent namespace now. Like Interface1 from Class1 for example. This does not work:

namespace App\Package1

Class1 implements App\Interface1
{
    //implement some functions here...
}

The Autoloader trys to include App\Package2\Class1\App\Interface1 then.

Best regards,

Manuel

1 Answer 1

2

the symfony's classloader works great:)

In this case, it's a php syntax problem.

You need to import the namespace with "use" or more easily you just need a backslash in front of the classname

for example:

namespace App\Package1;

use App\Interface1;

Class1 implements Interface1
{
    //implement some functions here...
}

or

namespace App\Package1;

Class1 implements \App\Interface1;
{
    //implement some functions here...
}
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.