Skip to content
Advertisement

Class SimpleXMLIterator not found in zend framework 1 when zf create project ZendApp with PHP7

I downloaded this zend framework zf 1.12.20 from their official site

Unzipped it and added the path to library in php.ini and aliased bin/zf.sh in .bashrc as per this tutorial

Now when I do zf create project ZendApp, I get the following error:

nidhind@nidhind-Lenovo-B590 ~ $ zf create project zendapp
PHP Fatal error:  Uncaught Error: Class 'SimpleXMLIterator' not found in /usr/share/ZendFramework-1.12.20/library/Zend/Tool/Project/Profile/FileParser/Xml.php:109
Stack trace:
#0 /usr/share/ZendFramework-1.12.20/library/Zend/Tool/Project/Profile.php(106): Zend_Tool_Project_Profile_FileParser_Xml->unserialize('<?xml version="...', Object(Zend_Tool_Project_Profile))
#1 /usr/share/ZendFramework-1.12.20/library/Zend/Tool/Project/Provider/Project.php(91): Zend_Tool_Project_Profile->loadFromData()
#2 /usr/share/ZendFramework-1.12.20/library/Zend/Tool/Framework/Client/Abstract.php(324): Zend_Tool_Project_Provider_Project->create('/home/nidhind/z...', NULL, NULL)
#3 /usr/share/ZendFramework-1.12.20/library/Zend/Tool/Framework/Client/Abstract.php(318): Zend_Tool_Framework_Client_Abstract->_handleDispatchExecution(Object(Zend_Tool_Project_Provider_Project), 'create', Array)
#4 /usr/share/ZendFramework-1.12.20/library/Zend/Tool/Framework/Client/Abstract.php(241): Zend_Tool_Framework_Client_Abstract->_handleDispatch()
#5 /usr/share/ZendFr in /usr/share/ZendFramework-1.12.20/library/Zend/Tool/Project/Profile/FileParser/Xml.php on line 109

Fatal error: Uncaught Error: Class 'SimpleXMLIterator' not found in /usr/share/ZendFramework-1.12.20/library/Zend/Tool/Project/Profile/FileParser/Xml.php:109
Stack trace:
#0 /usr/share/ZendFramework-1.12.20/library/Zend/Tool/Project/Profile.php(106): Zend_Tool_Project_Profile_FileParser_Xml->unserialize('<?xml version="...', Object(Zend_Tool_Project_Profile))
#1 /usr/share/ZendFramework-1.12.20/library/Zend/Tool/Project/Provider/Project.php(91): Zend_Tool_Project_Profile->loadFromData()
#2 /usr/share/ZendFramework-1.12.20/library/Zend/Tool/Framework/Client/Abstract.php(324): Zend_Tool_Project_Provider_Project->create('/home/nidhind/z...', NULL, NULL)
#3 /usr/share/ZendFramework-1.12.20/library/Zend/Tool/Framework/Client/Abstract.php(318): Zend_Tool_Framework_Client_Abstract->_handleDispatchExecution(Object(Zend_Tool_Project_Provider_Project), 'create', Array)
#4 /usr/share/ZendFramework-1.12.20/library/Zend/Tool/Framework/Client/Abstract.php(241): Zend_Tool_Framework_Client_Abstract->_handleDispatch()
#5 /usr/share/ZendFr in /usr/share/ZendFramework-1.12.20/library/Zend/Tool/Project/Profile/FileParser/Xml.php on line 109

I tired by relocating the framework to my home folder but the error didn’t resolve. I tried using zf 1.12.19, still no luck.

Then to verify if zf is not seen by php I executed the following code from this site and it worked perfectly:

<?php
require_once 'Zend/Pdf.php';

/* create a new pdf document */
$pdf = new Zend_Pdf();

/* create a page */
$page = new Zend_Pdf_Page(Zend_Pdf_Page::SIZE_LETTER_LANDSCAPE);

/* setup font */
$font = Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_HELVETICA);

/* write text to page */
$page->setFont($font, 48);
$page->drawText('Hello, World!', 250, 500);

/* add page to document */
$pdf->pages[] = $page;

/* save pdf */
$pdf->save('/home/nidhind/Public/hello.pdf');
?>

It seems like the zf.sh file is causing this error. It would be great if any one could help. I ‘am running apache2 2.4.18 and PHP 7.0.8 on Linux Mint 18. I know zf1 is outdated but I need it now.

Advertisement

Answer

Too bad no body could help me so far. Fortunately accidently while working for another app, I found the issue from https://linuxconfig.org/moodle-exception-call-to-undefined-function-xml-parser-create.

The reason for the exception was the missing xml library in PHP 7.

After installing php7.0-xml by

apt-get install php7.0-xml

every thing worked fine. Zend Framework requires a xml library for PHP

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement