Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/security/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/meteor/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Symfony Console命令:找到文件,但类不在其中,类名或命名空间可能有输入错误。_Symfony_Symfony 2.3 - Fatal编程技术网

Symfony Console命令:找到文件,但类不在其中,类名或命名空间可能有输入错误。

Symfony Console命令:找到文件,但类不在其中,类名或命名空间可能有输入错误。,symfony,symfony-2.3,Symfony,Symfony 2.3,首先,我要做的是学习使用文档创建自己的控制台命令 我想准确地复制文档中正在执行的操作 这就是我到目前为止得到的 <? // src/Gabriel/LiveLoginBundle/Command/GreetCommand.php namespace Gabriel\LiveLoginBundle\Command; use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand; use Symfony\Component

首先,我要做的是学习使用文档创建自己的控制台命令

我想准确地复制文档中正在执行的操作

这就是我到目前为止得到的

<?
// src/Gabriel/LiveLoginBundle/Command/GreetCommand.php
namespace Gabriel\LiveLoginBundle\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 GreetCommand extends ContainerAwareCommand
{
    protected function configure()
    {
        $this->setName('demo:greet')
        ->setDescription('Greet someone')
        ->addArgument('name', InputArgument::OPTIONAL, 'Who do you want to greet?')
        ->addOption('yell', null, InputOption::VALUE_NONE, 'If set, the task will yell in uppercase letters');
    }

    protected function execute(InputInterface $input, OutputInterface $output)
    {
        $name = $input->getArgument('name');

        if ($name)
        {
            $text = 'Hello '.$name;
        }
        else
        {
            $text = 'Hello';
        }

        if ($input->getOption('yell'))
        {
            $text = strtoupper($text);
        }

        $output->writeln($text);
    }
}
但是由于某种原因,它抛出了这个错误,它似乎找不到类

找到文件,但类不在其中,类名或 命名空间可能有输入错误


PS:已尝试删除缓存。默认情况下,您的PHP配置PHP.ini不允许您使用短开头标记

<? ?>
<?= ?>
最好的办法是用正确的标签替换短标签Try
short_open_tag=On