0

I want to use the class Zend_Db (and other Zend classes later). However, after 5 hours I am still not able to access this class. Could someone please point me towards a solution? It would already be helpful to know which of the hundreds files in the Zend framework contains this class? Thanks a million in advance!

More details on my problem: I am receiving the following error message

Fatal error: Class 'Zend_Db' not found

upon doing the following:

1) Downloaded Zend 2.2.5 and moved it to my server at /home/www/Zend/library

2) Added following line to php.ini: include_path=".:/home/www/Zend/library"

3) Ran following index.php:

    require_once 'Zend/Loader/AutoloaderFactory.php';
    require_once 'Zend/Loader/StandardAutoloader.php';
    require_once 'Zend/Loader/SplAutoloader.php';
    $options = array(Zend_Db::AUTO_QUOTE_IDENTIFIERS => true);

    $db = new Zend_Db_Adapter_Pdo_Mysql(array(
        'host'     => MYSQL_HOST,
        'username' => MYSQL_BENUTZER,
        'password' => MYSQL_KENNWORT,
        'dbname'   => MYSQL_DATENBANK,
        'options' => $options
        ));`

Background: It's my first time using Zend. I am working on an Apache Server with PHP 5.3.21. I am using Zend 2.2.5

tyrex
  • 8,208
  • 12
  • 43
  • 50
  • What does your error log say? – Ma'moon Al-Akash Jan 09 '14 at 12:23
  • Sorry, I don't know what "error log" means. I am just getting the error "Fatal error: Class 'Zend_Db' not found" on the browser. If you meant something different, then maybe you could please specify? – tyrex Jan 09 '14 at 12:28
  • There is a file that logs all errors in your web server, this file is called "error log", you may want to check this file using -propably- a "tail" command in order to get more information about the error that you are getting, if you are using Apache web server, this file typically is located at /var/logs/apache2/error-log – Ma'moon Al-Akash Jan 09 '14 at 12:31
  • the file has no record on this task that I performed - maybe there is also another file that tracks the directory that I am using for tests. Nevertheless it seems that I need to understand how to get Zend 2 working as I am missing apparently missing some fundamentals there... – tyrex Jan 11 '14 at 11:01

2 Answers2

3

The code you've included was written for ZF1, but you have downloaded ZF2. The two are not compatible. You need to either change your code to work with ZF2, or download the latest version of ZF1.

Tim Fountain
  • 33,093
  • 5
  • 41
  • 69
  • ok thanks for the info - could you point me to any ZF2 tutorials? I have really crawled in detail the internet but only those ZF1-snippets appear to me.. – tyrex Jan 09 '14 at 13:37
  • Update: Just found http://stackoverflow.com/questions/13578349/using-zend-db-zf2-module-outside-of-zf2-mvc which might point me to the solution. I am checking it out at the moment – tyrex Jan 09 '14 at 13:39
  • Yup, in particular, Sam's blog post: http://samsonasik.wordpress.com/2013/01/15/zend-framework-2-cheat-sheet-zenddb/ should help you. I'd recommend using Composer to install the library if you can - it makes life easier in the long run. – Tim Fountain Jan 09 '14 at 13:40
  • After studying the article my problems remain. In fact, I couldn't even perform the step of running the command "composer install" because the command "composer" is not recognized. Subsequently I haven't got a file "autoload.php" to include /// I believe I am missing some fundamental things here, but haven't found yet a dummy-tutorial which would explain how to use Zend 2. Would be happy if anyone can point me towards one :) – tyrex Jan 11 '14 at 10:42
  • http://getcomposer.org/doc/00-intro.md has installation instructions for Composer – Tim Fountain Jan 11 '14 at 12:49
1

If you really want to use Zend_DB, you can use the composer autoloader and setup a classmap. Define where the classmap should look and with ./composer.phar install you automagically generate a class-map in which composer will do the rest.

With ZF2 I presume you use composer, if not, use it. This website also contains the basics on how to use it:
- http://getcomposer.org/doc/04-schema.md#classmap

Anyone
  • 2,814
  • 1
  • 22
  • 27