我刚刚开始了我的第一个symfony项目,并且我在更复杂的情况下遇到了上述错误。为了缩小范围,我创建了一个新项目,但错误仍然存在:/
我失望了:
cd / var / www
sudo symfony new em
cd em
sudo mkdir src / AppBundle / Entity
sudo touch src / AppBundle / Entity / Company.php
sudo chmod -R 777 *
php bin / console doctrine:database:create // db symfony
php bin / console doctrine:generate:entities AppBundle
sudo touch src / AppBundle / Controller / CompanyController.php
sudo chmod -R 777 * //无法写入缓存
导航到http://em.at/app_dev.php/companies时出现错误!
我已经尝试过Uncaught PHP Exception Doctrine\ORM\ORMException: "Unknown Entity namespace alias 'AppBundle'."
了所以
php bin / console cache:clear
导致
[Symfony的\元器件\文件系统\异常\ IOException异常]
无法删除文件" / var / www / em / var / cache / de~ / twig / 2b / 2bef18b12bca6cd9cb
d50ce5b194c23fdc85bb73d29114f27fb3793b7f085d8a.php":。
所以我手动删除了它们
sudo rm -R cache / de~
sudo rm -R cache / dev
但错误仍然存在。任何人都知道什么是错的?。
我的档案:
<?php
// src/AppBundle/Entity/Company.php
namespace AppBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity
* @ORM\Table(name="company")
*/
class Company
{
/**
* @ORM\Column(type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* @ORM\Column(type="string", length=100)
*/
private $name;
}
和
<?php
// src/AppBundle/Entity/CompanyController.php
namespace AppBundle\Controller;
use AppBundle\Entity\Company;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Request;
class CompanyController extends Controller
{
/**
* @Route("/companies", name="company_list")
*/
public function listAction(Request $request)
{
$companies = $this->getDoctrine()->getRepository('Appbundle:Company')->findAll();
// replace this example code with whatever you need
return $this->render('company/list.html.twig', [
'base_dir' => realpath($this->getParameter('kernel.root_dir').'/..').DIRECTORY_SEPARATOR,
'companies' => $companies
]);
}
}
答案 0 :(得分:0)
您是否在var文件夹上设置了文件权限。形成上述消息,看起来你可能没有这样做。这是您需要的参考:
https://symfony.com/doc/current/setup/file_permissions.html
另外,以防万一:
<form action="confirma_comanda2.php" method="post">
<tr><td>nume: <input name="nume_client" type="text"></td></tr>
<tr><td>email: <input name="email_client" type="email"></td></tr>
<tr><td>telefon: <input name="telefon_client" type="number"></td></tr>
<tr><td>judet: <select name="judet_client">
<option value="Arges">Arges</option>
<option value="Arad">Arad</option>
<option value="Timis">Timis</option>
</select></td></tr>
<tr><td>adresa: <input name="adresa_client" type="text"></td></tr>
<?php
for ($i=0; $i<$countArray; $i++) {
$confirmForm =' <input type="hidden" name="prettotal" value=" echo '.$pretTotal[$i].'">
<input type="hidden" name="produse" value=" echo '.$PRODUSE.'">
<input type="hidden" name="produseNume" value=" echo'.$produseNume.'">
<input type="hidden" name="cantitate" value=" echo'.$cantitate.'">
<input type="hidden" name="size" value=" echo'.$size.'">
<input type="hidden" name="totalComanda" value="'.$total.'">';
}
?>
<tr><td><input type="submit" name="sumbitDateClienti" value="Trimite Comanda"></td><td><input type="button" onClick="location.href='index.php';" value="Inapoi la Cumparaturi">
确保您已满足所有其他要求。 这会为你带来很多悲伤。