Skip to content

Instantly share code, notes, and snippets.

@microlancer
Created September 30, 2012 17:17
Show Gist options
  • Select an option

  • Save microlancer/3807707 to your computer and use it in GitHub Desktop.

Select an option

Save microlancer/3807707 to your computer and use it in GitHub Desktop.
Exception strangeness...
<?php
/**
* Zend Framework (http://framework.zend.com/)
*
* @link http://github.com/zendframework/ZendSkeletonApplication for the canonical source repository
* @copyright Copyright (c) 2005-2012 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\Db\Adapter\Adapter as DbAdapter;
use Zend\Authentication\Adapter\DbTable as AuthAdapter;
use Zend\Authentication\AuthenticationService;
use Zend\Authentication\Storage\Session as SessionStorage;
use Zend\Authentication\Storage\StorageInterface;
use Zend\Cache\Storage\Adapter\Memcached;
use Zend\Cache\Storage\Adapter\MemcachedOptions;
use Zend\Session\SessionManager;
use Zend\Session\SaveHandler\Cache;
class Module
{
public function onBootstrap($event)
{
$event->getApplication()->getServiceManager()->get('translator');
$eventManager = $event->getApplication()->getEventManager();
$moduleRouteListener = new ModuleRouteListener();
$moduleRouteListener->attach($eventManager);
}
public function getConfig()
{
return include __DIR__ . '/config/module.config.php';
}
public function getAutoloaderConfig()
{
return array(
'Zend\Loader\StandardAutoloader' => array(
'namespaces' => array(
__NAMESPACE__ => __DIR__ . '/src/' . __NAMESPACE__,
),
),
);
}
public function getServiceConfig()
{
return array(
'factories' => array(
'Application\Model\AccountTable' => function($serviceManager) {
$dbAdapter = $serviceManager->get('Zend\Db\Adapter\Adapter');
$table = new AccountTable($dbAdapter);
return $table;
},
'Zend\Db\Adapter\Adapter' => function($serviceManager) {
$config = $serviceManager->get('config');
$config = $config['db'];
$dbAdapter = new DbAdapter($config);
return $dbAdapter;
},
'Zend\Authentication\Adapter\DbTable' => function($serviceManager) {
$dbAdapter = $serviceManager->get('Zend\Db\Adapter\Adapter');
$authAdapter = new AuthAdapter($dbAdapter);
return $authAdapter;
},
'Zend\Authentication\AuthenticationService' => function($serviceManager) {
$config = $serviceManager->get('config');
$config = $config['memcached'];
$memcachedOptions = new MemcachedOptions($config);
$memcachedStorage = new Memcached($memcachedOptions);
try {
$space = $memcachedStorage->getAvailableSpace();
} catch (Exception $e) {
echo 'Should catch it, but it doesnt... Why?';
die;
}
$authService = new AuthenticationService();
$memcachedSaveHandler = new \Zend\Session\SaveHandler\Cache($memcachedStorage);
$sessionManager = new SessionManager(null, null, $memcachedSaveHandler);
$sessionStorage = new SessionStorage(null, null, $sessionManager);
$authService->setStorage($sessionStorage);
return $authService;
},
),
);
}
}
@microlancer
Copy link
Author

Zend\Cache\Exception\RuntimeException
File:
/home/thorie/github/thorie7912/ZendSkeletonApplication/vendor/ZF2/library/Zend/Cache/Storage/Adapter/Memcached.php:193
Message:
SOME ERRORS WERE REPORTED
Stack trace:
#0 /home/thorie/github/thorie7912/ZendSkeletonApplication/module/Application/Module.php(78): Zend\Cache\Storage\Adapter\Memcached->getAvailableSpace()
#1 [internal function]: Application{closure}(Object(Zend\ServiceManager\ServiceManager), 'zendauthenticat...', 'Zend\Authentica...')
#2 /home/thorie/github/thorie7912/ZendSkeletonApplication/vendor/ZF2/library/Zend/ServiceManager/ServiceManager.php(684): call_user_func(Object(Closure), Object(Zend\ServiceManager\ServiceManager), 'zendauthenticat...', 'Zend\Authentica...')
#3 /home/thorie/github/thorie7912/ZendSkeletonApplication/vendor/ZF2/library/Zend/ServiceManager/ServiceManager.php(801): Zend\ServiceManager\ServiceManager->createServiceViaCallback(Object(Closure), 'zendauthenticat...', 'Zend\Authentica...')
#4 /home/thorie/github/thorie7912/ZendSkeletonApplication/vendor/ZF2/library/Zend/ServiceManager/ServiceManager.php(455): Zend\ServiceManager\ServiceManager->createFromFactory('zendauthenticat...', 'Zend\Authentica...')
#5 /home/thorie/github/thorie7912/ZendSkeletonApplication/vendor/ZF2/library/Zend/ServiceManager/ServiceManager.php(412): Zend\ServiceManager\ServiceManager->create(Array)
#6 /home/thorie/github/thorie7912/ZendSkeletonApplication/module/Application/src/Application/Controller/IndexController.php(25): Zend\ServiceManager\ServiceManager->get('Zend\Authentica...')

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