0
votes

Hi I have problem when I am trying to include any standard library. I already import Zend folder into this path

/project
    /library
        /

Here is my script:

 require_once 'Zend/Db/Table/Abstract.php';

 require_once APPLICATION_PATH.'/models/ContentNode.php';

class Application_Model_Page extends Zend_Db_Table_Abstract
{


    public function createPage ($name, $namespace, $parentId = 0)
    {
        //create the new page
        $row = $this->createRow();
        $row->name = $name;
        $row->namespace = $namespace;
        $row->parent_id = $parentId;
        $row->date_created = time();
        $row->save();
        // now fetch the id of the row you just created and return it 
        $id = $this->_db->lastInsertId();
        return $id;
    }

here is error message I am getting

Warning: include_once(Zend\Db\Table\Abstarct.php) [function.include-once]: failed to open stream: No such file or directory in C:\Zend\Apache2\htdocs\zendproject\library\Zend\Loader.php on line 146

2
Where you include the ZEND path? - Gabriel Santos
Actually, I installed zend server so it is included. - Akrambek
if you have Zend server installed, you have no reason to move ZF to your application path. your php.ini should already have it as part of the include_path so it just works. look for [Zend] include_path=".;C:\Zend\ZendServer\share\ZendFramework\library" way at the bottom of your php.ini. - RockyFord
Please post your application.ini and bootstrap.php for this application, I feel the problem is there. - RockyFord
remove the _initAutoload() from your bootstrap. It's not needed for this application under ZF 1.11. If you leave it in you'll be attempting to duplicate and override the default autoloader. All you'll need to do is to add to your application.ini autoloaderNamespaces[] = "CMS_" - RockyFord

2 Answers

2
votes

according to your error, you spelled 'abstract' incorrectly.

Warning: include_once(Zend\Db\Table\Abstarct.php) [function.include-once]:
 failed to open stream: No such file or directory in
 C:\Zend\Apache2\htdocs\zendproject\library\Zend\Loader.php on line 146

also there should be no requirement to add include files in the model if you are using the Zend Framework as an mvc application. The autoloader should include the required files automatically.
Make sure your application.ini contains the line:
includePaths.library = APPLICATION_PATH "/../library"
I can never remember if a namespace needs to be added when ZF is in the library, so I'll assume it's required. You may try and add the line autoloaderNamespaces[] = "Zend_" to your application.ini, it won't hurt and might help make sure the Zend library is included. so that the library is properly included. Then your library folder should look like:

/project_path
    /library
        /Zend

It looks like you are running through the code in the book "Pro Zend Framework Techniques". This book used the Zend Framework version 1.8. You are likely using ZF 1.11. If so there are several things to be careful of, as there have been some changes since version 1.8. If you are new to ZF this should not be your first book as it will drive you crazy making things work, if you are familiar with ZF it contains some great info.

I have the updated code for this book, so if you need more help...

1
votes
set_include_path(get_include_path() . PATH_SEPARATOR . 'ZEND/FRAMEWORK/PATH');