0

On my local machine the script works fine, but when I put it on the server I get:

application/hooks/zend.php

[9]: require_once(Loader/Autoloader.php) [function.require-once]: failed to open stream: No such file or directory

Stack Trace

application/hooks/zend.php [9]: require_once( )

system/core/Kohana.php [199]: include( application/hooks/zend.php )

system/core/Bootstrap.php [37]: Kohana::setup( )

index.php [106]: require( system/core/Bootstrap.php )

I'm trying to load zend into Kohana 2.3. Here's zend.php

<?php defined('SYSPATH') OR die('No direct access allowed.');
/**
* zend.php
*/
ini_set('include_path', ini_get('include_path').
PATH_SEPARATOR.SYSPATH.'vendor/');
ini_set('include_path', ini_get('include_path').
PATH_SEPARATOR.SYSPATH.'vendor/Zend/');
require_once 'Loader/Autoloader.php';
Zend_Loader_Autoloader::getInstance();
?>

I've been stumped on this for about 2 days and I've followed many many different tutorials and different routes of doing it. So any direction would be great. Currently my file structure and set up matches this

bradenkeith
  • 2,397
  • 1
  • 17
  • 26
  • 3
    Loader/Autoloader.php is not being found in any of the directories in your include path INI directive. If you do an "echo ini_get('include_path');", what does it look like? and where is your Loader/ directory? – Jay Taylor Aug 30 '10 at 17:25
  • .:/usr/share/pear1 is what it is after the ini_set which is no different than prior to ini_set (where as it changes on localhost). So what I'm getting from that test is that my server is not support ini_set? – bradenkeith Aug 30 '10 at 17:32
  • It sounds like your include path is being overwritten, which would explain why you can't call require_once on the file. The next step I would advise would be to do that `echo ini_get..` call beginning from the earliest script entry point and moving it further along until you can identify where things are going awry. – Jay Taylor Aug 30 '10 at 17:42
  • The require is being executed directly after the ini_set though? – bradenkeith Aug 30 '10 at 17:46
  • From the top of the index.php page, the ini_get path stays the same. Seems to be an issue with ini_set in my opinion. Any ideas? – bradenkeith Aug 30 '10 at 17:50
  • > The require is being executed directly after the ini_set though? Right, when the require is executed, your ini path does not contain the parent directory of 'Loader/', so it fails since it can't find the file. If the include path is already messed up at top of index.php, then you should look at your PHP configuration, specifically `php.ini`. Open up php.ini and search for `include_path`, and add the public webserver directory, e.g. `/var/www/my.hostname.or.whatever/public_html/`. After you've done that, if it doesn't "just work", show me the result of `echo ini_get..` again. – Jay Taylor Aug 30 '10 at 17:56
  • If the public_html directory isn't being auto-added to the include path by the apache php module, I'd be concerned that the real problem is somewhere else. However, the instructions in my previous comment may at least get you running...but it seems like there might be a configuration problem such that some PHP code which clobbers your include path variable is running before index.php. – Jay Taylor Aug 30 '10 at 18:11
  • set `include_path` to: `/var/www/vhosts/nedcoleman.com/httpdocs/`, `:/var/www/vhosts/nedcoleman.com/httpdocs/`, `.:/var/www/vhosts/nedcoleman.com/httpdocs/` all of which returned `.:/usr/share/pear1` for ini_get. I wasn't too sure how to start the ini definition, so I tried a few... – bradenkeith Aug 30 '10 at 18:11

2 Answers2

3

this works every time for me:

<?php require_once($_SERVER['DOCUMENT_ROOT'] . '/Loader/Autoloader.php'); ?>
Matt Ryan
  • 1,717
  • 2
  • 20
  • 30
  • 1
    Bam - there it is. It broke it on my local server but I feel like I can patch that. So far this works well... I'll see if there are any side effects. – bradenkeith Aug 30 '10 at 19:30
  • if the path is set wrong require_once will through a fatal error. try echoing out the document root on a working page to make sure it's where you think it is. sometimes it's out of place. – Matt Ryan Aug 30 '10 at 19:52
0

How about this?

if ($path = Kohana::find_file('vendors', 'Zend/library/Zend/Loader'))
{
    ini_set('include_path', ini_get('include_path').PATH_SEPARATOR.dirname(dirname($path)));
    require_once 'Zend/Loader/Autoloader.php';
    Zend_Loader_Autoloader::getInstance();
}

Source: kohana-zend (kolanos)

The Pixel Developer
  • 13,282
  • 10
  • 43
  • 60
  • ini_set is where I was having problems. This is just a different way of writing what I have as my source code. Thanks for the response. – bradenkeith Aug 30 '10 at 19:32