0

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.

1
  • Are you using Windows or a Unix-inspired OS? Commented Dec 31, 2011 at 13:53

4 Answers 4

1

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.

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

3 Comments

the zend framework is in library/zend, and there is a file called server.php at svc.almacivor.net/library/Zend/Rest/Server.php
if your Zend files are under "library" dir, why you are requesting the server.php file from path Application/Zend ? Now I can understand, you are not bootstrapping. It is not best practice to create the file in public folder, You should intanciate Zend_Rest_Controller and create your file as a controller / Action. May this article help you understand techchorus.net/create-restful-applications-using-zend-framework
well it looked that way but just seems to give me a ton of http 500s
0

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";

6 Comments

This may break "everything else". You should use set_include_path(get_include_path() . PATH_SEPARATOR . $new_include_path); instead to avoid side effects resulting from the fact, that you kick the original include path.
tried that and no joy. - even did the full svc.almacivor.net/library/Zend and that didnt work either- somewhat flummoxed.
@brx_virgil I suppose you didnt just copy/pasted this thing, it was was demonstration... in your case, judging from the Error, the $new_include_path should be /home/bestpubi/public_html/svc/public/library
yep. i did change it accordingly but stil doesn't seem to want to know.
@brx_virgil try changing require_once '../application/Zend/Rest/Server.php'; to require_once 'Zend/Rest/Server.php'; OR require_once '../library/Zend/Rest/Server.php';
|
0

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.

3 Comments

totally bizarre, that doesn't seem to work either. think i'm just goign to try with the muneer's bootstrapping approach. Not feeling the love for PHP so far, but my hosting provider wants a lot more for java hosting... cheers
getting very close to just paying for java hosting and forgeting this php thing.....
@brx_virgil Well whatever it is that's blocking you exists too in java. Your stuff should work bothing to do with the langage what you are doing is trivial.
0

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.

1 Comment

unfortunately my hosting provider don't provide ssh access so I can't get to terminal on the box...

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.