laminas / laminas-session

Object-oriented interface to PHP sessions and storage
https://docs.laminas.dev/laminas-session/
BSD 3-Clause "New" or "Revised" License
55 stars 25 forks source link

Fix the configuration index name #2

Open weierophinney opened 4 years ago

weierophinney commented 4 years ago

Looks like the example code in bootstrapSession() expects to read a key sessionand not session_manager from the configuration.

Provide a narrative description of what you are trying to accomplish:


Originally posted by @ekarakashi at https://github.com/zendframework/zend-session/pull/124

weierophinney commented 4 years ago

We have ticket #71 to fix the whole documentation for Session Manager (I think we should at least mention default factory we have in the package).

Also I'd like to point https://github.com/zendframework/zend-session/pull/61 where we made a change.

/cc @froschdesign


Originally posted by @michalbundyra at https://github.com/zendframework/zend-session/pull/124#issuecomment-544695940

weierophinney commented 4 years ago

@webimpress

I think we should at least mention default factory we have in the package

We must document the factory because this is the way the user should go. These manual configuration must be removed from all packages.


Originally posted by @froschdesign at https://github.com/zendframework/zend-session/pull/124#issuecomment-544699438

genby8 commented 4 years ago
'service_manager' => [
        'factories' => [
            SaveHandlerInterface::class => SaveHandlerDbFactory::class,
            SaveHandlerDbFactory::class => InvokableFactory::class,
        ]
]
namespace App\Session\SaveHandler;

use Interop\Container\ContainerInterface;
use Laminas\Db\Adapter\Adapter;
use Laminas\Db\TableGateway\TableGateway;
use Laminas\ServiceManager\Factory\FactoryInterface;
use Laminas\Session\SaveHandler\DbTableGateway;
use Laminas\Session\SaveHandler\DbTableGatewayOptions;

class SaveHandlerDbFactory implements FactoryInterface
{
    public function __invoke(ContainerInterface $container, $requestedName, array $options = null)
    {
        return new DbTableGateway(
            new TableGateway( 'session', $container->get(Adapter::class)),
            new DbTableGatewayOptions()
        );
    }
}

This best way inject?