I haven’t done this in years, so I have little input that I can give unfortunately.
Can you turn up Apache’s logging, particularly of the rewrite module and see anything interesting there.
When you say that you get a 404, are you getting a Slim 404 page or an Apache 404 page? If it’s an Apache one, then it’s a Rewrite issue. If it’s a Slim one, then it’s related to matching the URL.
Thank you for the help. I have read pretty much the same thing on many posts, and it finally clicked what I am doing differently! If I place my entire slimphp app inside of a subdirectory, it works perfectly. How flipping obvious is that…
What I was trying to do was to have the slim app outside my docroot and then have an /api/index.php that simply required the app that lived outside docroot. Does that make sense? I created a repo to help see what I was trying to accomplish. Let me know if this is possible.
In the Slim skeleton, the ‘public’ directory is already defined as ‘docroot’ in order to have the Slim app ‘outside’ the Slim app. Just make sure that your Apache web server document-root points to the ‘public/’ directory and that’s it.
My app is something that customers will integrate with their existing websites. This is why I thought it would be nice to allow them to install the app outside docroot then simply require the bootstrap file where they wanted the entrypoint for the app to be.
Installing the entire app within docroot does work but it would be nice if I could figure out how to do it the other way.
P.S. This is the Total CMS project that you helped me get started. I am shipping beta 1 next week.
I am fine with not storing the slim app outside of docroot. Everything works perfectly with Apache. However, I cannot get it to work in a sub-directory with the PHP built-in server.
@odan Should your Slim Skeleton repo work with the PHP server in a built-in directory?
Thanks @odan. I was able to get everything working. I ended up creating my own custom middleware that allowed me to properly route things. The problem is that in the particular
environment that I am building this to support, I do not have control over the PHP server that is running. It’s a total hack but it’s only used while in development mode and it seems to be working well.