Hi, how are you? Today we’re going to talk a little bit about Slim Framework. This is a micro-framework for PHP that helps us develop web applications and APIs faster. At its core, Slim is a dispatcher that receives an HTTP request. It then invokes a callback routine and returns an HTTP response. Additionally, it is recommended when an application needs to be prototyped in a short time. In other words, it works very well when we only need php to launch the rest operations against the database requested by a client application. An additional advantage is that its learning curve is very fast. Consequently, it can be learned in a few sessions. Well, in this post we will see how to install Slim Framework in Windows 10.
Prerequisites.
In order to install Slim Framework on Windows 10, a number of dependencies must be satisfied. Fortunately, in osradar.com we explain in detail how to install each one.
- PHP installed in version 7.1 or higher. See this post for how to install it.
- Apache server installed. You can also use Nginx or any other web server.
- Finally, it is necessary to have installed PHP composer. Please check this post to see how to install it.
Preparing the installation of Slim Framework on Windows 10.
In the first place, head for the following address: C:Apache24. Then create a folder and assign it the name of your preference. Please note that the framework will be installed in this folder.
Downloading and installing Slim Framwork using Composer.
Once the folder is created, open a Command Prompt inside it. Forthwith, add the following command:
composer require slim/slim:"^3.0"
Just wait a few minutes while the framework is installed.
Testing Slim Framework.
After we have installed Slim, we will test its operation by launching a Hello World. With that intention, it is necessary to create an index.php file inside the program folder. With that in mind, use the text editor of your choice. In this case, I will use Notepad++. Please add the following text to the file:
<?php
require "vendor/autoload.php";
$app = new Slim\App();
$app->get("/",function(){
echo "Hello World";
});
$app->run();
?>
After adding the above text, then save the file and name it index.php
Finally, open the web browser and open localhost accompanied by the Slim installation folder. In this case: localhost/slim_osradar/
Ultimately we have seen how to install Slim Framework on Windows 10. This is a great option to get started in the world of PHP programming. This is all for now before I say goodbye I invite you to see our post about upgrading to Windows 10 for free.