0
votes

I've been trying to get to grips with zend framework and a bit of php and am having problems with (I think) some sort of path setting.

Basically I'm having some problems with getting a simple page to work.

I have a standard directory structure from the zend quickstart sample. It has the structure:

app
->public
->library 

etc.

When I create the following "hello.php" file in the public directory, I get an error from "require-once"

Warning: require_once(/../application/Zend/Rest/Server.php) [function.require-once]: failed to open stream: No such file or directory in /home/bestpubi/public_html/svc/public/hello.php on line 2 Fatal error: require_once() [function.require]: Failed opening required '/../application/Zend/Rest/Server.php' (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/bestpubi/public_html/svc/public/hello.php on line 2

My hello.php file looks like this:

<?php
require_once '../application/Zend/Rest/Server.php';
/**
* Say Hello
*/
function sayHello()
{
return 'finally';
}
$server = new Zend_Rest_Server();
$server->addFunction('sayHello');
$server->handle();
?>

I could really do with some help as this is driving me a bit mad, and I'm sure it's something silly.

4
Are you using Windows or a Unix-inspired OS?Eugen Rieck

4 Answers

1
votes

You are requesting the required library file as follows.

require_once '../application/Zend/Rest/Server.php';

The error message indicates that, there is no such file in the path specified.

Usuallay zend framework contains it 'Zend' library inside /library directory. If you have the Zend directory in your downloaded ZendFramework files, copy it to /library directory. So that the Zend directory structure would be as follows

/library/Zend

This is a simple way to get started. Once you are familiar with the environment, try to use include path in your setting.

0
votes

Try

$new_include_path = "/home/www/app/library/";
set_include_path ( get_include_path() . PATH_SEPARATOR . $new_include_path); )

to define the include path of your ZF library. Put this on the top of your page, before Including any ZF file.

Edit: I assumed you are on linux, if you are on windows, change path accourdingly

$new_include_path = "c:\\www\\app\\library";
0
votes

Looking at your website it seems the index.php from /public works fine. So I would suggest copy pasting the code that's in there to set paths for zf into hello.php and it should work.

0
votes

First thing is create your files in application folder.

And If You are using Linux follow the steps,

To use Zend library you can create a short cut to zend library from your library. From terminal go to your 'library' directory run the command

ln -s 'path to your zend library'

It will create a shortcut.