I am starting to work with Symfony2 and so far I like the Framework very much. I only got one problem, all URLs get a slash added at the end after every link click.
Example:
I am on: http://symblog.dev/app_dev.php
now the home button points to http://symblog.dev/app_dev.php/
when i click it I am on: http://symblog.dev/app_dev.php/
and there is another slash at the end of the home URL, so it is now: http://symblog.dev/app_dev.php//
this keeps going as often as I click the button, what causes things like the debug toolbar to crash because the ajax url does not match with multiple slashes etc. It occurs on every URL on the site not just the debug toolbar ajax.
I hope someone got an idea what the problem might be.
Environment
vagrant debian 7 vm
apache2, php 5.5, OPcache, hhvm
mysql 5.5
code lies in a shared folder with all permissions, host system is win 8.1
Screenshot: http://picload.org/image/cgardll/screenshot2014-08-2320.14.47.png
// please excuse misspellings etc. since i don't speak english natively
I'de recommend reading the documentation on routing for symfony2:
http://symfony.com/doc/current/book/routing.html
This should give you a good idea of how the routing in the framework works so you don't run into this issue in the future.
Hope this was helpful.
EDIT:
Take a look at this as well
http://blog.christian-baer.com/index.php/trailing-slash-in-symfony-route/
Related
I apologize in advance if this issue has been posted before. My problem is that my programmer had to bail on my project due to personal reasons and left me alone with a 95% finished site. I have some basic experience with ASP classic but PHP is fairly new to me.
FireFTP scr_shot: https://www.dropbox.com/s/9lws1u0sl8k93rg/fireftp_scr_shot.jpg
To shorten it up; (with Xampp installed) I have downloaded my site to the hard-drive and is now trying to get it work on 'localhost'. Immediately I sense the absence of an index-file.
Do I need to make one myself for the use in localhost? In that case, what am I looking for?
Thank you in advance.
First if you want to make an index-file of your current website, you have to put all your pages in a folder in
xampp/htdocs/
e.g
C:\Xampp\htdocs\mywebsite
then after you make a directory just visit the url like this:
localhost/mywebsite
, remember to put an index file inside the mywebsite folder.
It turned out that there was a MYSQL-database behind the site which I had no idea about or any knowledge of how to get around.
I had the database taken off and written the code into the site-files.
Afterwards everything worked as laid out above comments.
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.
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.
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.
I am an autodidact so dont know much about conventional web development however, I have wrote a complete social networking website yet I dont know how to debug. My website has some problems and I need to learn debuggin things around/
First of all I need instructions how to install Xdebug on WAMP (since I use phpDesigner). I tried a lot using tutorials on the web everytime I get a new error. I also tried puting it in the /ext/ directory and activating it from the WAMP PHP Extensions menu. Doesnt Work!
So if anyone odf you out there uses PHPDesigner with Xdebug (not the package that comes along, rather install it on WAMP) please help me and I would really be grateful. BTW PHP version is 5.3.0
Next thing is this is how is the the control flow of my website :-
htaccess -> redirect everything to index.php if file doesn't exist.
index.php ->
include all libraries (__autoload).
initialize classes.
Get the $_SERVER['REQUEST_URI'] to get the $page.
If $page is found
Check if the user is logged in,
if yes then include view/$page.php
or else redirect to login.php page
If page is not found then
redirect to 404.php
Is this control flow good for debugging? because I really cant understand the real MVC concept so I created something like this.
There is a tutorial for installing XDebug for use with phpDesigner here.
MVC is an organizing principle (also called a "design pattern"). It can be helpful keeping logically similar parts of a project together, and encouraging clean interfaces between them, but—especially for low complexity projects—strict MVC modeling isn't always an improvement.
You ask:
Is this control flow good for debugging?
Debugging is to identify flaws in programs. Writing a program to be easy to debug is like intentionally driving a car off the left side of the road so you'll know where to direct an ambulance to find you. Granted—there are small things which can be done to greatly improve debugability. But the point is to architect any control structure so it naturally expresses the algorithm. By doing that, it is far more likely to avoid the need to debug. Anything you can do to write correctly functioning code is justifiable.
Your control flow is clear to me. I wouldn't have any qualms about working on it.
Use xDebug.
Its very easy to install and use.
and you can download xDebug from here http://www.xdebug.org/
step by step tutorial for setup xdebug with WAMP is available at sachithsays.blogspot.com/