<?php
namespace Utils;
use SymfonyComponentDependencyInjectionContainerInterface;
class Sessions
{
private $container;
private $session;
public function __construct(ContainerInterface $container)
{
$this->container = $container;
$this->session = $this->container->get('session');
}
在控制器使用$this->get('utils.sessions');提示
Attempted to load class "Sessions" from namespace "Utils".
Did you forget a "use" statement for another namespace?
命名空间具体怎么弄,放在Bundle中申明就没有这个错误,还是命名空间的问题,具体还没找到解决方案
能提供具体你的文件的结构是什么杨的吗?
其实主要问题如果你想把你的PHP文件放到其他文件夹, 你需要在composer.json的文件里面声明路径,然后再update
比如说: