Skip to content

Instantly share code, notes, and snippets.

@Xerkus
Last active Feb 26, 2017
Embed
What would you like to do?
<?php
/**
* Global Configuration Override
*
* You can use this file for overriding configuration values from modules, etc.
* You would place values in here that are agnostic to the environment and not
* sensitive to security.
*
* @NOTE: In practice, this file will typically be INCLUDED in your source
* control, so do not include passwords or other sensitive information in this
* file.
*/
use Zend\Session;
return [
'session_config' => [
'config_class' => Session\Config\SessionConfig::class,
'name' => 'myapp',
],
'session_manager' => [
'session_storage' => Session\Storage\SessionArrayStorage::class,
'validators' => [
Session\Validator\RemoteAddr::class,
Session\Validator\HttpUserAgent::class,
],
],
];
<?php
/**
* @link http://github.com/zendframework/ZendSkeletonApplication for the canonical source repository
* @copyright Copyright (c) 2005-2016 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
/**
* List of enabled modules for this application.
*
* This should be an array of module namespaces used in the application.
*/
return [
'Zend\Session',
'Zend\Router',
'Zend\Validator',
'Application',
];
<?php
/**
* @link http://github.com/zendframework/ZendSkeletonApplication for the canonical source repository
* @copyright Copyright (c) 2005-2016 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
namespace Application;
use Zend\Mvc\ModuleRouteListener;
use Zend\Mvc\MvcEvent;
use Zend\Session\SessionManager;
use Zend\Session\Config\SessionConfig;
use Zend\Session\Container;
use Zend\Session\Validator;
class Module
{
const VERSION = '3.0.2dev';
public function getConfig()
{
return include __DIR__ . '/../config/module.config.php';
}
public function onBootstrap($e)
{
$eventManager = $e->getApplication()->getEventManager();
$moduleRouteListener = new ModuleRouteListener();
$moduleRouteListener->attach($eventManager);
$this->bootstrapSession($e);
}
/**
* @param MvcEvent $e
*/
public function bootstrapSession($e)
{
$session = $e->getApplication()
->getServiceManager()
->get(SessionManager::class);
$session->start();
$container = new Container('initialized');
if (isset($container->init)) {
return;
}
$session->regenerateId(true);
$container->init = 1;
}
}

installed zf and zend session

composer create-project -n -sdev zendframework/skeleton-application path/to/install
composer require zendframework/zend-session

and followed the instructions from https://github.com/zendframework/zend-session/blob/master/doc/book/manager.md

exception from php internal server

PHP Fatal error:  Uncaught Zend\ServiceManager\Exception\ServiceNotCreatedException: Configuration is missing a "session_config" key, or the value of that key is not an array in (...)vendor/zendframework/zend-session/src/Service/SessionConfigFactory.php:40
Stack trace:
#0 (...)vendor/zendframework/zend-servicemanager/src/ServiceManager.php(750): Zend\Session\Service\SessionConfigFactory->__invoke(Object(Zend\ServiceManager\ServiceManager), 'Zend\\Session\\Co...', NULL)
#1 (...)vendor/zendframework/zend-servicemanager/src/ServiceManager.php(198): Zend\ServiceManager\ServiceManager->doCreate('Zend\\Session\\Co...')
#2 (...)vendor/zendframework/zend-session/src/Service/SessionManagerFactory.php(74): Zend\ServiceManager\ServiceManager->get('Zend\\Session\\Co...')
#3 (...)vendor/zendframework/zend-servicemanager/src/ServiceManager.php(750): Zend\Session\Service\SessionManagerFactory->__invoke(Object in (...)vendor/zendframework/zend-session/src/Service/SessionConfigFactory.php on line 40
HP Fatal error:  Uncaught Zend\ServiceManager\Exception\ServiceNotCreatedException: Configuration is missing a "session_config" key, or the value of that key is not an array in (...)vendor/zendframework/zend-session/src/Service/SessionConfigFactory.php:40
Stack trace:
#0 (...)vendor/zendframework/zend-servicemanager/src/ServiceManager.php(750): Zend\Session\Service\SessionConfigFactory->__invoke(Object(Zend\ServiceManager\ServiceManager), 'Zend\\Session\\Co...', NULL)
#1 (...)vendor/zendframework/zend-servicemanager/src/ServiceManager.php(198): Zend\ServiceManager\ServiceManager->doCreate('Zend\\Session\\Co...')
#2 (...)vendor/zendframework/zend-session/src/Service/SessionManagerFactory.php(74): Zend\ServiceManager\ServiceManager->get('Zend\\Session\\Co...')
#3 (...)vendor/zendframework/zend-servicemanager/src/ServiceManager.php(750): Zend\Session\Service\SessionManagerFactory->__invoke(Object in (...)vendor/zendframework/zend-session/src/Service/SessionConfigFactory.php on line 40

exception from apache

( ! ) Fatal error: Uncaught Zend\ServiceManager\Exception\ServiceNotCreatedException: Configuration is missing a "session_config" key, or the value of that key is not an array in /home/rodrigo/sites/bffc/rh/zf3/vendor/zendframework/zend-session/src/Service/SessionConfigFactory.php on line 40
( ! ) Zend\ServiceManager\Exception\ServiceNotCreatedException: Configuration is missing a "session_config" key, or the value of that key is not an array in /home/rodrigo/sites/bffc/rh/zf3/vendor/zendframework/zend-session/src/Service/SessionConfigFactory.php on line 40
Call Stack
#	Time	Memory	Function	Location
1	0.0002	357200	{main}( )	.../index.php:0
2	0.0027	369720	Zend\Mvc\Application::init( )	.../index.php:40
3	0.0287	1117424	Zend\Mvc\Application->bootstrap( )	.../Application.php:273
4	0.0334	1308184	Zend\EventManager\EventManager->triggerEvent( )	.../Application.php:161
5	0.0334	1308184	Zend\EventManager\EventManager->triggerListeners( )	.../EventManager.php:143
6	0.0407	1508440	Application\Module->onBootstrap( )	.../EventManager.php:271
7	0.0408	1510360	Application\Module->bootstrapSession( )	.../Module.php:32
8	0.0408	1510360	Zend\ServiceManager\ServiceManager->get( )	.../Module.php:42
9	0.0408	1510360	Zend\ServiceManager\ServiceManager->doCreate( )	.../ServiceManager.php:198
@rcapile
Copy link

rcapile commented Feb 26, 2017

( ! ) Notice: Array to string conversion in /home/rodrigo/sites/bffc/rh/zf3/vendor/zendframework/zend-session/src/Config/SessionConfig.php on line 88
Call Stack
#	Time	Memory	Function	Location
1	0.0000	357232	{main}( )	.../index.php:0
2	0.0006	367944	Zend\Mvc\Application::init( )	.../index.php:40
3	0.0135	900600	Zend\Mvc\Application->bootstrap( )	.../Application.php:273
4	0.0170	952176	Zend\EventManager\EventManager->triggerEvent( )	.../Application.php:161
5	0.0170	952176	Zend\EventManager\EventManager->triggerListeners( )	.../EventManager.php:143
6	0.0200	1146912	Application\Module->onBootstrap( )	.../EventManager.php:271
7	0.0201	1148704	Application\Module->bootstrapSession( )	.../Module.php:27
8	0.0201	1148704	Zend\ServiceManager\ServiceManager->get( )	.../Module.php:36
9	0.0201	1148704	Zend\ServiceManager\ServiceManager->doCreate( )	.../ServiceManager.php:198
10	0.0202	1149432	Zend\Session\Service\SessionManagerFactory->__invoke( )	.../ServiceManager.php:750
11	0.0202	1149432	Zend\ServiceManager\ServiceManager->get( )	.../SessionManagerFactory.php:74
12	0.0202	1149432	Zend\ServiceManager\ServiceManager->doCreate( )	.../ServiceManager.php:198
13	0.0202	1149808	Zend\Session\Service\SessionConfigFactory->__invoke( )	.../ServiceManager.php:750
14	0.0204	1158944	Zend\Session\Config\StandardConfig->setOptions( )	.../SessionConfigFactory.php:67
15	0.0204	1158984	Zend\Session\Config\StandardConfig->setOption( )	.../StandardConfig.php:116
16	0.0204	1159360	Zend\Session\Config\SessionConfig->setStorageOption( )	.../StandardConfig.php:147

( ! ) Fatal error: Uncaught Zend\Session\Exception\InvalidArgumentException: 'session.config' is not a valid sessions-related ini setting. in /home/rodrigo/sites/bffc/rh/zf3/vendor/zendframework/zend-servicemanager/src/ServiceManager.php on line 757
( ! ) Zend\ServiceManager\Exception\ServiceNotCreatedException: Service with name "Zend\Session\Config\ConfigInterface" could not be created. Reason: 'session.config' is not a valid sessions-related ini setting. in /home/rodrigo/sites/bffc/rh/zf3/vendor/zendframework/zend-servicemanager/src/ServiceManager.php on line 757
Call Stack
#	Time	Memory	Function	Location
1	0.0000	357232	{main}( )	.../index.php:0
2	0.0006	367944	Zend\Mvc\Application::init( )	.../index.php:40
3	0.0135	900600	Zend\Mvc\Application->bootstrap( )	.../Application.php:273
4	0.0170	952176	Zend\EventManager\EventManager->triggerEvent( )	.../Application.php:161
5	0.0170	952176	Zend\EventManager\EventManager->triggerListeners( )	.../EventManager.php:143
6	0.0200	1146912	Application\Module->onBootstrap( )	.../EventManager.php:271
7	0.0201	1148704	Application\Module->bootstrapSession( )	.../Module.php:27
8	0.0201	1148704	Zend\ServiceManager\ServiceManager->get( )	.../Module.php:36
9	0.0201	1148704	Zend\ServiceManager\ServiceManager->doCreate( )	.../ServiceManager.php:198

@rcapile
Copy link

rcapile commented Feb 26, 2017

( ! ) Fatal error: Uncaught Zend\ServiceManager\Exception\ServiceNotCreatedException: Configuration is missing a "session_storage" key, or the value of that key is not an array in /home/rodrigo/sites/bffc/rh/zf3/vendor/zendframework/zend-session/src/Service/StorageFactory.php on line 39
( ! ) Zend\ServiceManager\Exception\ServiceNotCreatedException: Configuration is missing a "session_storage" key, or the value of that key is not an array in /home/rodrigo/sites/bffc/rh/zf3/vendor/zendframework/zend-session/src/Service/StorageFactory.php on line 39
Call Stack
#	Time	Memory	Function	Location
1	0.0000	357472	{main}( )	.../index.php:0
2	0.0002	368184	Zend\Mvc\Application::init( )	.../index.php:40
3	0.0041	900120	Zend\Mvc\Application->bootstrap( )	.../Application.php:273
4	0.0048	951696	Zend\EventManager\EventManager->triggerEvent( )	.../Application.php:161
5	0.0048	951696	Zend\EventManager\EventManager->triggerListeners( )	.../EventManager.php:143
6	0.0057	1146432	Application\Module->onBootstrap( )	.../EventManager.php:271
7	0.0057	1148224	Application\Module->bootstrapSession( )	.../Module.php:26
8	0.0057	1148224	Zend\ServiceManager\ServiceManager->get( )	.../Module.php:35
9	0.0057	1148224	Zend\ServiceManager\ServiceManager->doCreate( )	.../ServiceManager.php:198

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment