Do we have to use MAMP or XAMPP when developing in Slim?

I have seen tutorials that use a local server such as MAMP or XAMPP, but I am unclear as to its necessity. Initially I was able to get a running framework of Slim without these services, but all the tutorials are saying to use XAMPP or MAMP, but when I tried implementing them and configuring the vhosts file and so on, that’s when everything started to go down hill.

Also, why are the tutorials leading us to post the code snippet on the home page of the slim framework site when index.php is already populated with some code?

So do we need MAMP or not because I am able to get a server going with just this command in the terminal: php -S -t public public/index.php.

Please help.

No, you don’t need to use MAMP, XAMPP, etc. As you discovered you can use PHP’s built in server if you would like.

As to your index.php question, I’m not certain what you are asking. The index.php file is acting as the front controller. Most people use it to setup any global needs, link to files organizing routes and dependencies, then calling $app->run(); See for example

1 Like

@tflight, thank you for your response. I have seen tutorials where the index.php came empty and the moderator pasted the code that is on the front page of the slimframework website which was odd because my index.php was already populated with code. So I guess I wasn’t sure whether I was supposed to replace the code snippet it came with and instead use the one on the slim framework homepage.

The snippet code on the homepage is the basic, minimum code required to demonstrate a Slim app. You could put that all into an index.php file, run it, and it should work. However as your application grows in routes, dependencies, and other setup stuff you would likely split out some of that stuff. For example the get /hello/{name} route and other routes might be put into a routes.php file, etc.

1 Like