Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/236.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/symfony/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 创建服务时出现命名空间错误_Php_Symfony - Fatal编程技术网

Php 创建服务时出现命名空间错误

Php 创建服务时出现命名空间错误,php,symfony,Php,Symfony,这里是Symfony2新手 我尝试在我的应用程序中创建一个服务。我跟着火车走 这是我的密码: 文件BC/MBundle/Resources/config/services.yml: --- services: metas: class: BC\MBundle\Metas\Metas 文件BC/MBundle/Metas <?php namespace BC\MBundle\Metas; class Metas { public function q

这里是Symfony2新手

我尝试在我的应用程序中创建一个服务。我跟着火车走

这是我的密码:

文件BC/MBundle/Resources/config/services.yml:

---
services:
    metas:
        class: BC\MBundle\Metas\Metas
文件BC/MBundle/Metas

<?php
namespace BC\MBundle\Metas;    
class Metas {
    public function queryAllCategories() {
        return array();
    }
}
  • 移动

    文件BC/MBundle/Metas

    到BC/MBundle/Metas/Metas.php

  • 尝试使用清除缓存

    php app/console cache:clear
    

    用于生产环境


  • 将显示相同的消息。
    Attempted to load class "Metas" from namespace "BC\MBundle\Metas".
    Did you forget a "use" statement for another namespace?
    
    php app/console cache:clear
    
    php app/console cache:clear --env=prod