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

4
  • What does your error log say? Commented Jan 9, 2014 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? Commented Jan 9, 2014 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 Commented Jan 9, 2014 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... Commented Jan 11, 2014 at 11:01

2 Answers 2

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.

Sign up to request clarification or add additional context in comments.

5 Comments

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..
Update: Just found stackoverflow.com/questions/13578349/… which might point me to the solution. I am checking it out at the moment
Yup, in particular, Sam's blog post: samsonasik.wordpress.com/2013/01/15/… should help you. I'd recommend using Composer to install the library if you can - it makes life easier in the long run.
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 :)
getcomposer.org/doc/00-intro.md has installation instructions for Composer
1
+50

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.