Configure slim routing on debian with apache web server

Hi, perhaps someone around here can help me.

I created a Slim project on my mac, which is an API which provides some data from MySql Database.
On my development machine (mac) it works find. I can request the API from front end Applications (which is an Android / IOs app) by sending a HTTP request to my mac’s IP address and add the route I defined via Slim Framework. To that point everything is fine.

Problem

To test the project on a server I chose a raspbian on a raspberry pi. I have set up apache web server, php and mysql on the debian machine. I can show a phpinfo(). Therefore I know that php and apache works fine.

Then I copied my project to the raspbians /var/www/html/ folder. But my API is not available now.
I enabled mod_rewrite. My .htaccess file looks like the one in the installation guide of the slim framework. In my apache2.conf file I changes AllowOverride option to “All” in the /var/www/ directory entry. Then restarted apache service.

My project structure is “pojectname/src/public/index.php” for the index file.
So the complete route to my index file is /var/www/html/pojectname/src/public/index.php.

It seems that Slim is not able to route to my methods…The code should be correct, due to the fact that same code works on dev machine. It seems to be a permission or configuration problem. Can someone provide some help?

Greetings

You can first try to eliminate other problems, to be sure it’s Slim that is the ‘bad guy’,
What is your index file has just phpinfo() inside?
Do you see the stuff you expect to see?

If so, try to debug your application just from the point that the routes are loaded, and see what the app does.

this is what I would call: the Sherlock Holmes way :wink:

I figured out the problem through looking up the error in the error_log file of apache.

The problem was that in my index.php file I call the following code to dynamically load my php classes:

spl_autoload_register(function ($classname) {
require ("…/classes/" . $classname . “.php”);
});

On my mac it worked, if the class file is called “myclass.php” and in the file the Class itself it called “MyClass”. On the mac a file called MyClass.php is searched an myclass.php is found and used. On the debian system the search for the file is case sensitive and the class files need to be named exactly as the Class they hold. So I have to rename the class of the example to MyClass.php.
Wondered about that, because the OS are similar to each other…but that was the problem. Thanks for your reply anyways.

Perhaps write a classloader function, that will give a nice error with enough info to solve it quickly.
Good you found it, and beter: you wrote back so future people can see how you solved it :slight_smile: