简体   繁体   English

Symfony2控制台命令

[英]Symfony2 console command

I followed Symfony2 create a basic command line . 我遵循Symfony2 创建基本命令行

<?php
// application.php

use Acme\Command\GreetCommand;
use Symfony\Component\Console\Application;

$application = new Application();
$application->add(new GreetCommand);
$application->run();

But I received the faltal Error: 但是我收到了致命错误:

Fatal error: Class 'Symfony\\Component\\Console\\Application' not found 致命错误:找不到类'Symfony \\ Component \\ Console \\ Application'

According to http://symfony.com/doc/current/components/using_components.html , you need to include the autoloader at the top of your PHP script. 根据http://symfony.com/doc/current/components/using_components.html ,您需要在PHP脚本的顶部包含自动加载器。

// update this to the path to the "vendor/"
// directory, relative to this file
require_once __DIR__.'/../vendor/autoload.php';

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM