Before Do Coding
Before we do coding there are some that should be needed. Such as:
MySQL
In this case i created a database as name db_movie_ _and consist of one table t_movie. To make that table so you can type like the code below
CREATE TABLE t_movie (id_movie int auto_increment primary_key not null, movie_title varchar(30) not null, movie_rate int not null )
.htaccess
Create one file named .htaccess. This file requires for clean url. Type like the code below
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [QSA,L]
Config
Create one file named config.phpin main directory and then type like the code below
function getDB() {
$dbhost="localhost";
$dbuser="root";
$dbpass="";
$dbname="db_movie";
$dbConnection = new PDO("mysql:host=$dbhost;dbname=$dbname", $dbuser, $dbpass);
$dbConnection->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
return $dbConnection;
}
index
Create one file too named index.php in main directory and then type like the code below. This code is needed to required file config and autoload which exist in SLIM directory
require 'vendor/autoload.php';
include 'config.php';
$app = new Slim\App();
//Your Main Code
$app->run();