I'm not sure if this is specifically Symfony2.4.0 related, but when I have a
<?php
namespace Wow\DogeBundle\Command;
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
class ProbeCommand extends ContainerAwareCommand
{
protected function configure()
{
$this ->setName('a:name')
->setDescription('wow');
}
protected function execute(InputInterface $input, OutputInterface $output)
{
$whenithappened = new \DateTime();
//more code
}
}
This code works alright, but what does the backward slash in front of DateTime() mean? As soon as I remove the backward slash I get this error:
PHP Fatal error: Class 'Wow\DogeBundle\Command\DateTime'
Is the backward slash some sort of escape to go back to the root namespace? I can have this code
<?php
$whenithappened = new \DateTime();
var_dump($whenithappened);
?>
which works fine with or without the backward slash in front of DateTime()
.