Created
September 30, 2012 23:51
-
-
Save microlancer/3808765 to your computer and use it in GitHub Desktop.
Seems like a bug in ZF2, fatal error on destruct
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
Run this from the root of ZendSkeletonApplication/ because it uses the same autoloader. | |
This bug shows an error like: | |
PHP Fatal error: spl_autoload(): Class Zend\Db\Sql\Insert could not be loaded in /home/thorie/github/thorie7912/ZendSkeletonApplication/vendor/ZF2/library/Zend/Db/Sql/Sql.php on line 77 | |
PHP Stack trace: | |
PHP 1. Zend\Session\SaveHandler\DbTableGateway->write() /home/thorie/github/thorie7912/ZendSkeletonApplication/vendor/ZF2/library/Zend/Session/SaveHandler/DbTableGateway.php:0 | |
PHP 2. Zend\Db\TableGateway\AbstractTableGateway->insert() /home/thorie/github/thorie7912/ZendSkeletonApplication/vendor/ZF2/library/Zend/Session/SaveHandler/DbTableGateway.php:147 | |
PHP 3. Zend\Db\Sql\Sql->insert() /home/thorie/github/thorie7912/ZendSkeletonApplication/vendor/ZF2/library/Zend/Db/TableGateway/AbstractTableGateway.php:258 | |
*/ | |
/** | |
CREATE TABLE IF NOT EXISTS `sessions` ( | |
`id` varchar(60) NOT NULL, | |
`data` longtext NOT NULL, | |
`lifetime` int(10) unsigned, | |
`modified` int(10) unsigned, | |
`name` varchar(60) DEFAULT 'PHPSESSID', | |
PRIMARY KEY (`id`) | |
) ENGINE=InnoDB DEFAULT CHARSET=utf8; | |
*/ | |
include 'init_autoloader.php'; | |
use Zend\Authentication\Storage\Session as SessionStorage; | |
use Zend\Session\SessionManager; | |
use Zend\Db\TableGateway\TableGateway; | |
use Zend\Session\SaveHandler\DbTableGateway; | |
use Zend\Session\SaveHandler\DbTableGatewayOptions; | |
$config = array( | |
'db' => array( | |
'driver' => 'Pdo', | |
'dsn' => 'mysql:dbname=skeleton;host=localhost', | |
'driver_options' => array( | |
PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES \'UTF8\'' | |
), | |
'username' => 'myuser', | |
'password' => 'mypass', | |
), | |
); | |
$dbAdapter = new \Zend\Db\Adapter\Adapter($config['db']); | |
$sessionTableGatewayOptions = new DbTableGatewayOptions(); | |
$sessionTableGatewayOptions->setDataColumn('data') | |
->setIdColumn('id') | |
->setLifetimeColumn('lifetime') | |
->setModifiedColumn('modified') | |
->setNameColumn('name'); | |
$sessionTableGateway = new TableGateway('sessions', $dbAdapter); | |
$dbSaveHandler = new DbTableGateway($sessionTableGateway, $sessionTableGatewayOptions); | |
$sessionManager = new SessionManager(null, null, $dbSaveHandler); | |
$sessionStorage = new SessionStorage('Zend_Auth', 'storage', $sessionManager); | |
//$sessionManager->writeClose(); // uncomment this line, and you won't get the PHP Fatal Error |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment