[英]Namespace not found class? symfony2
這里有新手問題,我用Sub文件夾MyBundle創建了一個名為MyServices的Bundle,
我創建了一個名為myAWServ的服務但是因為我正在調用$this->get('myAWS')->methodCall()
我收到以下錯誤:
CRITICAL - 致命錯誤:類'MyServices \\ MyBundle \\ myAWS \\ myAWS'未找到CRITICAL - 未捕獲PHP異常Symfony \\ Component \\ Debug \\ Exception \\ ClassNotFoundException:“嘗試從命名空間”MyServices \\ MyBundle \\ myAWS“加載類”myAWS“。您是否忘記了另一個命名空間的“use”語句?“ 在/home/sergio/Desktop/hello_symfony_heroku/app/cache/dev/appDevDebugProjectContainer.php第1755行
我已經審查了所有文件一百次,並且無法找到文件所遵循的問題:
<?php
//File Location : MyServices/MyBundle/Controller/myAWS.php
namespace MyServices\MyBundle\myAWS;
class myAWS
{
public function __construct($greeting)
{
$this->greeting = $greeting;
}
public function greet($name)
{
return $this->greeting . ' ' . $name;
}
}
使用bundle創建的Root文件(php app / console generate:bundle)
//Filesource : MyServices/MyBundle/MyServicesMyBundle.php
<?php
namespace MyServices\MyBundle;
use Symfony\Component\HttpKernel\Bundle\Bundle;
class MyServicesMyBundle extends Bundle
{
}
和services.yml
parameters:
myAWS.class: MyServices\MyBundle\myAWS\myAWS
services:
myAWSer:
class: "%myAWS.class%"
arguments: [teste]
我已經在AppKernel中加載了新的MyServices \\ MyBundle \\ MyServicesMyBundle(),
目前我正在做一個簡單的電話
<?php
namespace MyServices\MyBundle\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
class DefaultController extends Controller
{
public function indexAction($name)
{
die($this->get('myAWSer')->greet($name));
}
}
我也試過清除緩存。 對不起,很長的帖子,謝謝你提前。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.