2

我是 symfony2 的新手。我想让通用应用程序库类在所有应用程序中使用我在 Admin\FeatureBundle\Repository\ 目录中创建了新文件 AppUtils.php 并定义

<?php
namespace Admin\FeatureBundle\AppUtils;
use Doctrine\ORM\EntityRepository;
class AppUtils {
...

但是在控制器中

use Admin\FeatureBundle\Repository\AppUtils;

class FeatureController extends Controller
{

    public function editAction($id)
    {
        $em = $this->getDoctrine()->getManager();

        $entity = $em->getRepository('AdminFeatureBundle:Feature')->find($id);

        if (!$entity) {
            throw $this->createNotFoundException('Unable to find Feature entity.');
        }

        $editForm = $this->createForm(new FeatureType(), $entity);
        $deleteForm = $this->createDeleteForm($id);
        $data= AppUtils::AddSystemParameters( $data, $this, true );
      echo '<pre>$data::'.print_r( $data, true ).'</pre><br>';
...

我得到错误:

The autoloader expected class "Admin\FeatureBundle\Repository\AppUtils" to be defined in file "/mnt/diskC_XP/wamp5/www/wavendon-tenants/src//Admin/FeatureBundle/Repository/AppUtils.php". The file was found but the class was not in it, the class name or namespace probably has a typo.

如何解决?是否有更好的方法来制作通用应用程序库类?

4

1 回答 1

0

你有一个错字

<?php
namespace Admin\FeatureBundle\Repository;

use Doctrine\ORM\EntityRepository;
class AppUtils {
于 2013-02-08T12:56:53.377 回答