【问题标题】:Calling existing apache commands in Symfony Console在 Symfony 控制台中调用现有的 apache 命令
【发布时间】:2016-06-14 14:38:12
【问题描述】:

我正在尝试构建一个命令行应用程序,以帮助为我设置一个新的本地开发环境。它只是创建了一些文件来链接虚拟主机的东西。我没有手动做任何事情。

我只是不确定如何重新启动 apache 部分。这是我的主文件;

class SetupEnvironment extends Command
{
    public function configure()
    {
        $this->setName('new')
            ->setDescription('Set up a new development environment.')
            ->addArgument('name', InputArgument::REQUIRED, "Project or application name")
            ->addOption('sub_folder', null, InputOption::VALUE_OPTIONAL, 'Name of public folder', '');
    }

    public function execute(InputInterface $input, OutputInterface $output)
    {
        // make directory for development environment - done

        // create conf file and contents - done

        // create sym-link - done

        // add to pow - done

        // restart apache and powder up - not done

我今天才刚刚开始学习 Symfony 控制台/文件系统,所以不太确定调用已经存在的命令的正确方法,例如 sudo apachectl restart 然后 powder up

【问题讨论】:

  • 你能把你的问题说得更具体一点吗?

标签: php symfony symfony-console


【解决方案1】:

你可以使用exec命令:

exec('sudo apachectl restart');

【讨论】:

    【解决方案2】:

    尝试使用通过 php 代码运行命令行参数的exec() 命令。 http://php.net/manual/en/function.exec.php

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-11-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多