chtito Messages: 512 Registered: March 2006 Location: Sweden
Faithful Member
I'm desperate. I have loads of problems when moving my code to my web hosting place.
The server serves stuff that are at a specific place, say /home/foo/www so i put my project under 'foo' and made a symbolic alias from foo/myproject/web to www. Everything works so far.
My problems are:
1) I get a nagging
Undefined index: QUERY_STRING in /home/path/to/symfony/lib/request/sfWebRequest.class.php on line 343
error. What the hell is that "QUERY_STRING"? Why is it missing? Should i talk to my provider or is it a bug in symfony???
2) The (default) .htaccess file seems to be wrong. It drives me crazy. When i try to access an address like http://mysite.com/mainmodule/something/foo then ALL the relative addresses start with "mainmodule/something/foo". The style files addresses are "mainmodule/something/foo/css/whatever.css". Same with the javascript. What on earth is going on?
3) The auto generated modules don't work. There is a missing semicolon in the modules_moduleName_config_generator.yml.php cache file. I'm using php 5.0.5. Is that the reason why this cache file has a syntax error?
I have previously installed a symfony project on a server for which i am the admin and it was painful but installing it on a remote server, with ssh but without access to the logs is as close as one can get to hell on earth.
Other problem: my provider asks me to use php5 extensions to use php 5. Everything went berserk again. I changed some line in sfWebRequest.php wihtout understanding much of it (http://www.symfony-project.com/forum/index.php/t/2077/) and this problem seems away now. I also had to modify the .htacces file. Phew.
Welcome in a club of NO-PEAR shared hosting dummies .
I hope you know http://www.symfony-project.com/trac/wiki/InstallingSymfonyOn SharedHostNoSsh.
This indeed was very helpful for me. But installation procedure is definitly something to improve in symfony. Many people complain and for many it was a block-stopper.
chtito Messages: 512 Registered: March 2006 Location: Sweden
Faithful Member
My goodness! I think i figured out some of my problems here:
the Apache server on my hosting site behaves totally differently from the one i got at home (MAMP).
On this distant server:
- PATH_INFO array is always empty
- QUERY_STRING is not set unless there is a '?' in the url
- REQUEST_URI is set properly
- SCRIPT_NAME is wrong and equal to the REQUEST_URI variable
- ORIG_SCRIPT_NAME is right and should be used in sfWebRequest instead of SCRIPT_NAME
What a mess! With that Apache behaviour sfWebRequest is totally 'in the cabbages' one says in French or 'out on a bicycle' in Swedish, in other words totally useless. I hope i will find some time to rewrite the getPathInfo function to get it working on my installation.
cheers!
P.S. Any translation in English of that expression 'in the cabbages' would be greatly appreciated!
halfer Messages: 9535 Registered: January 2006 Location: West Midlands, UK
Faithful Member
In the UK, we like similies. We might sometimes say: "as useful as a chocolate teapot", or "as useful as a windscreen-wipers on a submarine" Remember Palestine
chtito Messages: 512 Registered: March 2006 Location: Sweden
Faithful Member
I'm slowly solving all the problems... Here are some news, for the interested ones.
1) I modified getPathInfo and getRelativeUrlRoot and it now seems to work. I will properly subclass sfWebRequest using factory.yml when everything goes smoothly.
2) Better but not quite functioning yet. It is a routing problem. I believe it is somehow related to the point 1)
Installing symfony on a shared host is really not for the faint hearted. Nobody should have to go through this ordeal. It is probably against the Geneva convention.
Seriously, symfony is impossible to install. This is chiefly due to sfWebRequest which is clearly not up to the task. I don't know enough about Apache, IIS and all the various QUERY_STRING, PATH_INFO, REQUEST_URI, ORIG_SCRIPT_FILENAME and all that paraphernalia but if you are expert in those you should think of rewriting the path functions of sfWebRequest to get it work on most platforms/installs. It would be greatly appreciated by the whole symfony community.
chtito Messages: 512 Registered: March 2006 Location: Sweden
Faithful Member
Still some more news. Point 2) was left unanswered. The problem came from a bug in sfWebController where the function genUrl directly calls $_SERVER['SCRIPT_NAME'] whereas it should call sfWebRequest::getScriptName(). I solved the problem by setting no_script_name to 'yes' in the settings, but the bug still remains in the symfony code.
Now there are still some quirks with javascript but i think i'm seeing the end of the tunnel.
All in all the causes of my problems were two genuine bugs plus the sfWebRequest class.
I really hope that some good samaritan will rewrite the tricky request related parts of the sfWebRequest class to ease installation on shared hosts...
I feel your pain. Spent about a week trying to move my app on the remote host. Finally through by the divine intervention I found a post with a similar issue, which seems to be fixed in 6.3. If I were you, I'd look for another host. It seems like your host is changing the default values for Apache server variables (i.e. QUERY_STRING) which is not a good thing.
after a day under very much time pressure I resolved my (very similar) hosting problems as follows:
I simply put the line
$_SERVER['SCRIPT_NAME'] = 'index.php';
in the beginning of index.php
In the end, with a front controller and a single app, that's always the case. With more apps you might consider $_SERVER['PHP_SELF'] instead.
Furthermore, to prevent the warning (sometimes breaking the layout and producing errors about sending HTTP headers after some content has already been sent...!), I just alter the webrequest class at line 348 or around, to check whether QUERY_STRING is already set.
so something like: if (isset($PathArray['QUERY_STRING'])) preg_replace ...
it's just that some servers do not supply any query string if no GET string has been put after your url. (like ?name=me)
chtito Messages: 512 Registered: March 2006 Location: Sweden
Faithful Member
Henk: do you have any idea of why some servers do not fill the QUERY_STRING if there is no '?' in the url? Is that the case on old Apache servers? IIS?
I'm sorry, I just found this out by trial and error. It must be something in the server's httpd.conf, because the installed version s are the latest and newest for all.. I'm sorry I can't help you
Hi,
First of all I have to say that your question is not very clear. My problem was that of an error that made it impossible to run symfony in the first place, so that sounds a little different than your problem... sorry if I misunderstood
How to remove the 'index.php' from your URL has been explained quite well in "the book", if that is your only problem: look at the 'routing' chapter. Possibly your hosting has the allow_override disabled for your page, then you'll have to negotiate with them!
here is a new patch i had to do for PHP5.2 with beta1.0 for the same hoster :
Here is the patch, in the case it could help someone :
settings.yml
path_info_array: SERVER
path_info_key: xx
because using path_info or orig_path_info, depending the pages, these vars are not always set or with bad values.
In lib/symfony/request/sfWebRequest.class.php replace the function by this one :
public function getScriptName()
{
$pathArray = $this->getPathInfoArray();
// patch for bad SCRIPT_NAME infos
return isset($pathArray['ORIG_SCRIPT_NAME']) ? $pathArray['ORIG_SCRIPT_NAME'] : '';
}