我有一個文件Orders.php,我想在其中使用類「測試」功能。問題在於類文件位於項目根文件夾中,但我無法使用它。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
如果應用程序位於項目或任何其他目錄的根目錄下,應如何使用類測試?我用「/」編寫名稱空間,所以它應該引用根目錄,不是?
爲什麼你不能把test.php放在AppBundle下? – Jeet