我正在尝试从命令行获取命令以使用symfony工作。 我有以下文件夹结构: p>
- app console li>
- src
- 来源 < UL>
- 命令
twitterCommand.php LI>
UL> LI>
UL> LI>
UL>
现在 在我的控制台文件中,我有以下代码: p>
#!/ usr / bin / env php &lt;?php require_once'/../vendor/autoload .php'; use Source \ Commands \ TwitterCommand; use Symfony \ Component \ Console \ Application; use Endroid \ Twitter \ Twitter; // API密钥 ... $ client = new Twitter($ consumerKey,$ consumerSecret,$ accessToken,$ accessTokenSecret); $ application = new Application(); $ application-&gt; add(new TwitterCommand($ client)); $ application-&gt; run(); code> pre>
然后在我的TwitterCommand.php中,我有以下内容: p>
&lt;?php namespace Source \ Commands; use Twitter; use Symfony \ Component \ Console \ Command \ Command; use Symfony \ Component \ Console \ Input \ InputArgument; use Symfony \ Component \ Console \ Input \ InputInterface; use Symfony \ Component \ Console \ Inp ut \ InputOption; use Symfony \ Component \ Console \ Output \ OutputInterface; use Symfony \ Component \ Console \ Formatter \ OutputFormatterStyle; class TwitterCommand extends Command { private $ client; public function __construct( Twitter $ client) { parent :: __ construct(); $ this-&gt; client = $ client; } 保护函数configure() { $ this this - &gt ; setName('freq:tweet') - &gt; setDescription('显示推文') } 保护函数execute(InputInterface $ input,OutputInterface $ output) { //检索 用户的时间线 $ tweets = $ twitter-&gt; getTimeline(array( 'count'=&gt; 5 )); //或者使用通用查询方法检索时间线 $ response = $ twitter-&gt; query('statuses / user_timeline','GET','json',$ parameters) ; $ tweets = json_decode($ response-&gt; getContent()); $ output-&gt; writeln($ tweets); } } code> pre> \ n
问题是我收到'致命错误:类'源\ Commands \ TwitterCommand'在C:...中找不到',错误发送在这一行: p>
$ application-&gt; add(new TwitterCommand($ client)); code> pre>
对于我做错了什么? / p> div>