Well, after a long distracting break, I’m back on this. I have torn the code back to (mostly, exactly) what is in the example, and I’m still getting this error:
ile:
/data/sites/portal-development/vendor/laminas/laminas-servicemanager/src/AbstractFactory/ReflectionBasedAbstractFactory.php:216
Message:
Unable to create service "Album\Controller\AlbumController"; unable to resolve parameter "sessionContainer" to a class, interface, or array type
In my Album Controller:
/** @var SessionContainer */
private SessionContainer $sessionContainer;
public function __construct(AlbumTable $table, SessionContainer $sessionContainer)
{
$this->table = $table;
$this->sessionContainer = $sessionContainer;
}
In my Album/config/module.config.php
'controllers' => [
'factories' => [
Controller\AlbumController::class => ReflectionBasedAbstractFactory::class
],
],
// The following section is new and should be added to your file:
// Stuff
'router' => [
'routes' => [
'album' => [
'type' => Segment::class,
'options' => [
'route' => '/album[/:action[/:id]]',
'constraints' => [
'action' => '[a-zA-Z][a-zA-Z0-9_-]*',
'id' => '[0-9]+',
],
'defaults' => [
'controller' => Controller\AlbumController::class,
'action' => 'index',
],
],
],
],
],
'view_manager' => [
'template_path_stack' => [
'album' => __DIR__ . '/../view',
],
],
and in my autoload/global.php:
return [
'db' => [
'driver' => 'Pdo',
'dsn' => 'mysql:dbname=asmorphic;web-02.asmorphic.com;charset=utf8',
'username' => 'asmorphic_portal',
'password' => 'xxxxxxxxx',
],
'service_manager' => [
'factories' => [
'Application\Db\WriteAdapter' => AdapterAbstractServiceFactory::class,
'Album\Model\Album' => ReflectionBasedAbstractFactory::class,
],
],
'session_containers' => [
Laminas\Session\Container::class,
],
'session_storage' => [
'type' => Laminas\Session\Storage\SessionArrayStorage::class,
],
'session_config' => [
'gc_maxlifetime' => 7200,
// …
]
];
Besides the parameter ordering within the Album Constructor - unless I’m missing something, they look completely the same as what is in the documentation. The error reads as if it can’t resolve ‘SessionContainer’ to something that exists.
Also, I presume when I get this working, if i want the session to be database bound, I would be tinkering with the ‘session_storage’ node?
Thanks again,
Martin