0

I'm having problems to implement Zend Framework on a website. It's not a fancy application, just uses some validation classes of Zend and the Zend_File_Transfer_Adapter_Http to upload files to the server. None of them work. The question is this: I've read that I should write a htaccess file to dictate the folder structure of the site, and also that mod_rewrite should be enabled. I don't know how to check for mod_rewrite since the control panel of my provider is very uninformative.

Anyway, I thought it was enough to include the Zend library like this:

$libreria = $_SERVER['DOCUMENT_ROOT'];
$libreria.='Zend/ZendFramework/library';
set_include_path(get_include_path().PATH_SEPARATOR.$libreria);
require_once('Zend/Loader/Autoloader.php');
Zend_Loader_Autoloader::getInstance();

But evidently it isn't. So another question I have is: ¿Should I instantiate the Autoloader differently, and should I specify a namespace like $loader = Zend_Loader_Autoloader::getInstance(); $loader->registerNamespace(something); I don't think so because as I said I'm simply trying to include the validation classes and the file upload classes into the web page.

Finally, I have set the class PHPMailer on some scripts to process user input, and whenever I seem to include the path to Zend Framework right, the page throws a 500 Internal Server error, while that doesn't happen if I write the path incorrectly (that's another issue, I think if I set the path relative to the document it doesn't work, like for example doing $libreria='Zend/ZendFramework/library'; will not work, since I see all the conditions that I set for validating the input fail no matter what I write.

Then the last question is: does PHPMailer have some incompatibility with Zend Framework? Excuse me for asking but I'm a newbie and although I've checked PHPMailer classes and do not find anything incompatible, I must ask.

Thanks in advance if anyone is willing to help

I should add also that I've tested this website on a local server and it works fine, the problem is in the remote server.

Also, I've read this article here and it's what I'm looking for, according to it I should be able to reference the standard classes of Zend using the new operator. But on the remote server I can't do this, only locally.

Searching a bit more I've read about the possible causes for the Zend Installation to fail here on this same site and that allows me to clarify my questions: first, I think none of those conditions may be failing, although as I said I haven't been able to check mod_rewrite on the remote server of my provider, second, my htaccess file is empty so there's no redirection rules (that should discard problems with Zend Framework interacting with an incorrect htaccess, correct me if I'm wrong), and third, I don't have access to php.ini file. So what can I do? Any suggestion is accepted as I've been struggling with this the whole morning and can't have a clue of what's going wrong.

Community
  • 1
  • 1
gerardo flores
  • 402
  • 1
  • 6
  • 28
  • Somehow I doubt that `$_SERVER['DOCUMENT_ROOT']` is the root of your Zend folder because that would be your public folder and we usually don't place our library into the public folder. – Adrian World Oct 22 '12 at 13:15
  • @AdrianWorld Thanks. I actually set it like that after having lots of trouble to put the include path. I tried with Unix root `/mypath/etcetera,etcetera` and with relative paths `../ZendFramework/` and none of them worked. I still have the problem. Recently I tried to change the .htaccess file after noticing the ZendFramework doesn't get loaded. I did `php_value include_path ":/home/u230474/Zend"`on the htaccess file but what happened was that none of the pages of the website could be viewed. So I removed the changes to the .htaccess. I posted another question about appending dir to htaccess – gerardo flores Oct 24 '12 at 00:43

1 Answers1

1

You have to make a distinction between Zend Framework as a MVC application and stand alone library. What you are after is the stand alone library and unfortunately a lot of documentation is about ZF as an MVC application. htaccess is required to kick off the MVC application.

For ZF as a stand alone library you need basically only one things: the correct path. And if you like you can add autoloader on to that but for ZF 1.x this is not a requirement because you have all the require_once in place.

Now you simply have to test if your path is working. If your require_once('Zend/Loader/Autoloader.php'); statement doesn't throw an error your basically all set because the include path expands the path in your require_once statement.

For the Autoloader. If this doesn't show an error you should be all set here too. You may have a conflict with your main application, though. Just after the Zend_Loader_Autoloader you should be able to instantiate a Zend class. Try to load one of the validators on the next line. If that works but not later in your application you probably have an other autoloader in that application that overrides the Zend loader.

Adrian World
  • 3,118
  • 2
  • 16
  • 25
  • Thanks, I've tested my script and added a few things, first a simple if else clause to see if the library is loaded. Now I got the correct path and it's loading. Then, on each of my validators, I put on a similar if else clause and they all output ok. I actually went through my code and found I declared two validators with the same variable. Fixed that, however, it seems like validators don't work, this only happens in Linux. I have Linux testing environment and there things don't work. I had to do `chown` on the backup of my site, on some folders. In Linux it don't work – gerardo flores Oct 25 '12 at 03:05