Skip to content

Instantly share code, notes, and snippets.

@Xerkus
Last active February 26, 2017 19:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Xerkus/b07175df66faf93cd0166a8ebf70018b to your computer and use it in GitHub Desktop.
Save Xerkus/b07175df66faf93cd0166a8ebf70018b to your computer and use it in GitHub Desktop.
<?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

( ! ) 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