I'm new to simfony2, so sorry for the newbie question.
When I try to use some classes, such as DirectoryIterator
or DOMDocument
I receive the following exception:
PHP Fatal error: Class 'My\TestBundle\Command\DirectoryIterator' not found in /var/www/simfony2/src/My/TestBundle/Command/TestCommand.php on line 214
If try to run the same code outside the simfony2 environment it code runs fine, phpinfo()
shows PHP Version => 5.3.10-1ubuntu3.4
and the include path is the default plus added ZF2.
Again, I know this is probably some configuration issue as it searches the class in my bundle rather than using the build-in php class but I can't figure out how to solve this.
Edit: This is copy of the code I'm trying to execute:
protected function execute(InputInterface $input, OutputInterface $output) {
$classes=get_declared_classes();
print_r($classes);
$d= new DirectoryIterator("/");
}
When I run the command I can see the class
...
[73] => DirectoryIterator
...
But I can't use it
This is namespace related!
Has nothing to do with symfony itself.
you should ad \
before a global class inside another namespace
$class = new \DirectoryIterator;
I suggest you read the php manual first before continuing with symfony!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With