-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
94 lines (82 loc) · 2.04 KB
/
index.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
<?php
/**
* Step 1: Require the Slim Framework
*
* If you are not using Composer, you need to require the
* Slim Framework and register its PSR-0 autoloader.
*
* If you are using Composer, you can skip this step.
*/
require 'Slim/Slim.php';
\Slim\Slim::registerAutoloader();
/**
* Step 2: Instantiate a Slim application
*
* This example instantiates a Slim application using
* its default settings. However, you will usually configure
* your Slim application now by passing an associative array
* of setting names and values into the application constructor.
*/
$app = new \Slim\Slim();
/**
* Step 3: Define the Slim application routes
*
* Here we define several Slim application routes that respond
* to appropriate HTTP request methods. In this example, the second
* argument for `Slim::get`, `Slim::post`, `Slim::put`, `Slim::patch`, and `Slim::delete`
* is an anonymous function.
*/
// GET route
$app->get(
'/',
function () {
}
);
// POST route
$app->post(
'/laptop',
function () {
$laptoppart = new \Aksesoris\Laptop();
$laptoppart->tambahLaptop($_POST['LaptopBrand'], $_POST['LaptopModel'], $_POST['LaptopReleaseYear']);
}
);
// POST route
$app->post(
'/parts',
function () {
$laptoppart = new \Aksesoris\Laptop();
$laptoppart->tambahParts($_POST['PartLaptopId'], $_POST['PartCategory'], $_POST['PartNumber'], $_POST['PartDescription']);
}
);
$app->post(
'/category',
function () {
$laptoppart = new \Aksesoris\Laptop();
$laptoppart->tambahCategory($_POST['PartCategoryName']);
}
);
// PUT route
$app->put(
'/put',
function () {
echo 'This is a PUT route';
}
);
// PATCH route
$app->patch('/patch', function () {
echo 'This is a PATCH route';
});
// DELETE route
$app->delete(
'/delete',
function () {
echo 'This is a DELETE route';
}
);
/**
* Step 4: Run the Slim application
*
* This method should be called last. This executes the Slim application
* and returns the HTTP response to the HTTP client.
*/
$app->run();