user2810081
user2810081

Reputation: 597

Symfony class not found but the class is defined

I've created a class in symfony, the file path is

src/Project/MemberBundle/Document/EnumMemberType.php

and the file looks like this

<?php

namespace Project\MemberBundle\Document;

class EnumMemberType {

    const VIP = 'xxxxx';

}  // class - EnumMemberType

but when i try to get the constant in this class in another file using the code

$memberType = \Project\MemberBundle\Document\EnumMemberType::VIP

i got the error

Attempted to load class "EnumMemberType" from namespace "Project\MemberBundle\Document". Did you forget a "use" statement for another namespace?

I really can't figure out why, the file name is the same with the class name, and it's under the right folder, and the file starts with <?php.

Can anyone see what else i'm missing? Thanks

Upvotes: 2

Views: 748

Answers (1)

Max Lipsky
Max Lipsky

Reputation: 1852

Maybe problem with namespace. You can write in the header of another file:

use Project\MemberBundle\Document\EnumMemberType

and

$memberType = EnumMemberType::VIP;

Upvotes: 1

Related Questions