Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community!
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.Start your free trial
Mister Moody41,768 Points
File Management / 'Routes' Issues when Building Navigation for Slim 3 Project
Calling @benpayne0925 ~
I just completed the the Introducing MVC Frameworks in PHP tutorial and I encountered an issue with my routes and/or PATHs for page templates.
I believe the issue that I am having is a file management problem, but I am not sure how to correct it. To the best of my knowledge, all routes are setup correctly. When I open the project in my
local environment (outside of workspace), I select the project
slim-framework located in the
C:\xampp\htdocs directory and it leads me to the project file directory, which lists all folders (ie vendor, public) and files required for the project.
So the first part of my inquiry deals with the 'why' must I 'click' the
public folder in order to view the project.
The second part of my inquiry has to deal with the actual
<links> for both
/contact. Upon entering the project, when I click either link, I receive the following error:
Object not found! The requested URL was not found on this server.
and what is obvious is that the actual file_path is not what I want or what I had actually coded. I went to great lengths to manipulate the file extension in
$app->['GET', 'POST'], '/' using all of the following:
'/contact' '/public/contact' 'slim-framework/public/contact'
without any positive results.
That said, IF I manually type
localhost:/slim-framework/public/contact, I can access the
contact form AND I am able to enter user input then submit the form as functionally designed. However, this is where I encountered a third problem which is why aren't CSS styles implemented on the
You can view the code for the project here.
code for this project works as described in my local environment, but workspaces will not display it in the same fashion.
(b) I fully intend to complete the tutorial, Templating with Twig, tomorrow as I have some experience using
twig and fondly remember being able to avoid the aforementioned issues!
Thank you in advance for any assistance you can provide!
Mister Moody41,768 Points
It took a while, but I figured out a successful solution to my problem. As mentioned by @amberstevens it is vital to point (the) server to the
public/ folder. I completed these objective by modifying two files:
Rewrite Base /Directive,
Rewrite ^ index.php [QSA,L]to
Rewrite ^ public/index.php [QSA,L]
.htaccessFile outside of the
public/folder then into the
<link href="css/styles.css"> to point to the server, as exemplified in step 2 above:
<script src="js/siteNav.js"> are loaded to the server in the same fashion as
<link>, simply modify the
src="" to point to the server!
Amber StevensTreehouse Project Reviewer
All right so for the first part of your question if you're working on you're local environment you are going to have to point your server to the public folder instead of just the main project file directory, otherwise it won't work. (I did the same thing initially when I did this course) And after looking at your workspace snapshot I just realized that you mentioned it does work in your local environment? As long as it does then you're doing all right... workspaces can be kind of "wonky" sometimes and the code doesn't always work as smoothly as it does in you local environment. I kind of remember having the same issue and once I downloaded the files and ran them all on my MAMP local env. then the project pages and links worked like they were supposed to. I'm not sure if this clears up your question or not, other than telling you sometimes things don't work like they should in workspaces (I've found this to be especially true with projects that require additional package installation and that have dependencies) And I compared your code to my own which I did when I completed this course and your code looks the same as mine so it SHOULD work on your local environment.... Let me know if you're still confused.