Symfony2无法加载服务


Symfony2 cannot load Service

我在Symfony中设置服务时遇到问题。当我运行应用程序时,我得到以下错误:

The autoloader expected class "HRPortal'SystemBundle'Services'SessionHandler" to be 
defined in file "/usr/local/apache2/htdocs/hrportal/src/HRPortal/SystemBundle/Services/SessionHandler.php". 
The file was found but the class was not in it, the class name or namespace probably has a typo.

类别如下:

<?php
namespace HRPortal'SystemBundle'Services'SessionHandler;
class SessionHandler
{
    public function __construct(RequestStack $requestStack)
    {
        $this->requestStack = $requestStack;
    }
    public function init($user)
    {
        ...
    }
    ....
}

我的服务声明如下:

parameters:
    session_handler.class:    HRPortal'SystemBundle'Services'SessionHandler
services:
    session_handler:
        class:            "%session_handler.class%"

我尝试过很多不起作用的事情,所以我想我应该问问社区,看看你能想出什么。

感谢

命名空间应该是

namespace HRPortal'SystemBundle'Services;

这样,完全限定的类名将是HRPortal'SystemBundle'Services'SessionHandler