在symfony2中制作通用的应用程序库类?

时间:2013-02-08 12:53:47

标签: symfony

我在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.

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

1 个答案:

答案 0 :(得分:0)

你有一个错字

<?php
namespace Admin\FeatureBundle\Repository;

use Doctrine\ORM\EntityRepository;
class AppUtils {