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