This post is to show how to install and configure slim framework on a VPS. We assume that you have a LAMP( or your preferred )stack installed on Ubuntu.if your application won’t be using MySQL, you can skip its installation. The minimum you will need installed is an Apache web server with Mod_Rewrite and PHP MINIMUM VERSION 5.3.
Quick Setup for Prerequisites
- Install Apache
apt-get update
apt-get install apache2
- Install PHP
apt-get install php5 libapache2-mod-php5 php5-mcrypt
3.Enable mod_rewrite
a2enmod rewrite
4.Modify the Apache configuration file
Modify the Apache configuration file and change AllowOverride None to AllowOverride All for the document root. Depending on your server setup, this configuration file could be any one of the following:
- /etc/apache2/apache2.conf
- /etc/apache2/sites-enabled/000-default
- /etc/apache2/sites-available/default
In the configuration file, locate the section that appears like the following:
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
5.Restart Apache
service apache2 restart
We assume that you are familiar with linux basics.
Slim Framework
Slim is one of the most popular, open source microframeworks available for PHP in the market. It is extremely efficient, fast, and easy to use. While it is ideal for developing small to medium sized web applications, it can also be used quite effectively to build large scalable PHP applications.
Slim comes with the most common utilities that you would expect in a framework:
- Easy to use, powerful, and flexible router
- Custom view to render templates
- Secure cookies
- HTTP caching
- Easy to use error handling and debugging
- Simple configuration
Installation
The process consists of three steps:
- Download Slim Framework
You can download the Slim Framework using the following command:
it will fetch the framework as a zip file and store it in the current directory with the name master
- Extract from the zip file.
This can be done with the help of the following command
unzip master -d ./
Note: incase you get an error that unzip isn’t installed, you can install it by using the command apt-get install unzip and then execute the above command to extract all the files. The command above will extract the files in a folder named codeguy-Slim-3a2ac72. A folder inside called Slim is the framework folder.
- Copy slim location to a common location.
We now have to copy the codeguy-Slim-3a2ac72/Slim folder to a common folder location like /usr/local/Slim from where it is accessible to all projects on the server that use Slim. This is to avoid duplication and prevent any maintenance issues that could arise from duplicate installations. Copy the folder using the following command:
cp -r ./codeguy-Slim-3a2ac72/Slim /usr/local/Slim
Note: The name of the extracted folder (codeguy-Slim-3a2ac72 in this case) might be slightly different if you download a different version of Slim. Make sure to modify the name of the folder in the above command accordingly.