2
我在symfony2中使用newby。我要讓常見的應用程序庫類的所有應用程序 使用我在管理\ FeatureBundle \庫\目錄下創建新文件AppUtils.php與定義在symfony2中製作通用的應用程序庫類嗎?
<?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.
如何解決?如果有更好的方法來製作通用的應用程序庫類?
你必須爲使用的服務。檢查http://symfony.com/doc/master/book/service_container.html – Pierrickouw 2013-02-08 12:58:09