私はOrders.phpというファイルを持っており、その中にクラス "Test"関数を使いたいと思います。問題は、クラスファイルがプロジェクトのルートフォルダにあることですが、使用できません。Symfony2クラスの使用
orders.php:
<?php
namespace AppBundle\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;
use Test;
protected function execute(InputInterface $input, OutputInterface $output)
{
ini_set('memory_limit', '4000M');
$test = new \Test(true);
exit;
}
とクラスファイルtest.phpをは次のとおりです。
<?php
namespace Test;
class Test
{
public function __construct($connect = null, $query = null)
{
if ($connect)
{
$this->connect();
}
if ($query)
{
$this->query($query);
}
}
}
は今test.phpをクラスファイルは、プロジェクトのルートフォルダにあります。 orders.phpファイルはpublic_html \ project \ src \ AppBundle \ Command \ order.phpにあります
クラステストがプロジェクトのルートまたは他のディレクトリにある場合はどうすればよいですか?私は "/"で名前空間を書くので、ルートディレクトリを参照する必要がありますか?
なぜ、AppBundleの下にtest.phpを置くことができないのですか? – Jeet