How do I ensure Symfony url_for() includes the PHP filename? - php

I've been battling to set up my Symfony project on a IIS web server, but have got it pretty much working.
I still can't get the nice URLs working though. When I use my dev environment, url_for generates URLs that look like .../frontend_dev.php/booking/create and everything works fine. But as soon as I use the prod environment url_for generates URLs that look like .../booking/create, which don't work presumably because of problems with the rewrite setup on IIS.
I don't want to try and get the proper rewrite working on IIS - I've stuffed around with that for ages now and have given up. If you have a silver bullet to fix my problem then I'd love to know but that's not really what the question is about.
I've found that calling .../index.php/booking/create works fine. Therefore I can fix my problem simply by ensuring that url_for always adds the filename. But how can I do this? I thought it might be just assuming index.php, so I made a copy called frontend.php but it still generates nice URLs, without the filename. It seems that if it's the dev environment, it adds the file, but if it's the prod environment, it hides it. Any ideas on how to override this?

In apps/appname/config/settings.yml, set no_script_name to false.
See the symfony Reference Book.

Related

Recess framework: Why am I getting a resource not found error when the file exists?

I'm thinking of using the Recess Framework which I downloaded as-is and followed the instructions studiously.
I'm using it with PHP (which is not the issue) and I seem to have it up and running... however I suspected something was slightly wrong with the pages being served (they did not contain the expected logos) so I inspected the code only to find out that the frameworks javascript and CSS files were "resource not found".
Incidentally the files exist at the path specified, and it's not a question that permissions are not set correctly - I checked that too.
But... I'm new to using "routing" through URLs as part of a MVC style and wondered if basically it has something to do with that.
If you download the framework, you'll find that the css and javascript files that make things look pretty, and activate certain parts of the framework toolset exists at the path:
http://localhost/yourRecessFolderName/index.php/recess/recess/apps/tools/public/js/shCore.js
but I get the dreaded 404 resource not found and this is preventing recess tools from working properly.
1) Has any body else had this or a similar problem?
2) What are the likely causes - help by pointing me in the right direction, unless you know the answer of course
On Recess v0.2, there is an .htaccess file in /apps that prevents direct access to children. You'd need to modify the .htaccess or configure something custom in mod_rewrite to allow the public folders under apps to be seen.
Well, seemed to fix it by downloading the most recent ("latest edge") version of the Recess framework from https://github.com/recess/recess
Everything seems to work fine now... hmm 0.o
When pass from Development to Production, the Recess Framework use a Cache for accelerate access to site. Is possible, in your case, that the cache content is wrong.
I suggest you access path /your/recess/path/data/temp and remove the files recess.php and sqlite-cache.db and try again.
I hope this help you.

CakePHP View URLs case-sensitive on one server, not another... why?

So I'm working on a CakePHP app, and had this line in one of my controllers:
$this->render('/vids/index');
It was working fine in MAMP. But on my live site (on MediaTemple) the controller couldn't find the view. After nearly pulling my hair out, I changed the line to this:
$this->render('/Vids/index');
And it worked.
Zuh? What could account for one system being case sensitive, and another not? My assumption is that this isn't a Cake issue, but I'm so baffled, I have no idea what's causing the discrepancy.
Simply because the 2nd line (uppercase Vids) is correct for a 2.0 app. And I guess there are differences between OSX (guess that from you using MAMP) and the servers OS you deploy the app on.
And why do you call render() manually? If you access /vids from the web it should automatically route to VidsController::index() and the controller will auto pick the right view.
Stands Vids for videos? Thats a horrible name. Abbreviations in code suck hard, if you want to rely on /vids for the URL use the router to rewrite that url.

Need to manipulate my url

I'm literally just starting to throw a site together today, so I don't even have much to work with yet, but I wanted to throw this out there so I'll have the information when I get there. I'm using WAMP (not sure which version, but downloaded within the last 6 months) and CodeIgniter 2.0.3. How do you manipulate the URL to do the following:
www.mysite.com/forums ==> forums.mysite.com
www.mysite.com/pc ==> pc.mysite.com
...
Would this be something that gets done with the htaccess file or some other way? And if it is the htaccess file, can someone provide specifics? I've looked into some sites that try to explain the htaccess file and they just confuse the crap out of me. :) lol. Oh yeah, and how will that look while looking at it on my local host? Currently my url looks like:
localhost/nothingbutcards/
Thank you all very much, hope you're enjoying your weekend.
Along with the reference material provided, the below should be a good starting point. It's an HTACCESS approach.
http://terriswallow.com/weblog/2008/htaccess-redirect-a-directory-to-a-subdomain-and-force-www/
I also wanted to mention, some web hosts now have this as an option in the configuration panel. Mine does, so I can go in, specify a subdomain and the path on the site it points to, and I'm done.

Zend Framework _Redirect() not working but header(location:) is working

I just got a new server and zend framework seems to be working properly EXCEPT, when a member posts something , they get a white page because $this->_redirect('/somepage'); doesn't work...
Am I unaware of some php setting or vhost setting I'm supposed to have? Header("Location:/somepage") works just fine.. :\
I've been looking through my logs with no luck. Also, my images aren't getting uploaded even when folders are set to 777...
I'm stumped. Let me know anything you need to help me fix this. It's a large site that is about to dissolve if this issue stays for longer than a couple days..
Some thoughts:
Xdebug installed? Sometimes Problems with crazy errors
Check Autoloader, possible redirect helper not found?
Check Zend Framework (all files available?)
Have a look into your php.log if exceptions are thrown.

Address of yii applications

I a new in Ubuntu and PHP frameworks. I had read the book about Yii name "Agile web application development with yii and php 5".
And this is the part of text:
Yii comes with a simple requirement checking tool. To invoke
the tool and have it verify the requirements for your installation, simply point
your browser to:
http://yourhostname/path/to/yii/requirements/index.php
I installed yii in /var/www/html/yii directory.
When I trying to open http://localhost/var/www/html/yii/requirements/index.php I get error message: Oops! This link appears to be broken.
Thanks for any help!
It depends on what your Apache server's "webroot" (localhost) is.
If your webroot is /var/www/html then el chief's answer would work:
http://localhost/yii/requirements/index.php
But your webroot is /var/www then you need to include the html part too:
http://localhost/html/yii/requirements/index.php
Basically "localhost" = /some/path (your Apache webroot), and when you are writing your URL you can just substitute the two.
So if "localhost" = /var/www instead of writing http://var/www/index.php you just write http://localhost/index.php
I hope this helps you with a higher-level understanding of what is going on.
This might help somebody, even though the question is already answered, since I had come searching here, even though the underlying issue was different.
I made the dumb mistake of extracting the downloaded yii archive into the www directory and accessing it via the http://localhost/yii/ URL, but took a while to realise that the extracted directory has the build#-release#, and once renamed to just "yii", things worked. Like I said, the problem you faced was different, but symptom was somewhat similar.
it should be http://localhost/yii/requirements/index.php
Also be aware that this book, while helpful, seems to have been rushed to publication. There's many fixes to be found on the Yii forums. I suggest you keep a tab open whenever you come across something that doesn't work or doesn't seem "right" in the book.

Categories