Last active
February 5, 2018 07:17
-
-
Save aasumitro/86545f01cf9f2bc7270273fb800bdcc9 to your computer and use it in GitHub Desktop.
slim index.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
use \Psr\Http\Message\ServerRequestInterface as Request; | |
use \Psr\Http\Message\ResponseInterface as Response; | |
//dengan adanya bagian ini qt dapat menggunakan library2 yang tersedia pada folder vendor | |
require __DIR__ . ('../vendor/autoload.php'); | |
//pada bagian ini kita membuat pengaturan dimana ketika | |
//ada kesalahan akan ditampilkan secara menyeluruh pada browser | |
//ingat ketika aplikasi kita sudah dalam mode rilis sebaiknya fitur | |
//menampilkan error secara mendetail dimatikan | |
$app = new \Slim\App([ | |
'settings' => [ | |
'displayErrorDetails' => true, | |
], | |
]); | |
//pada bagian ini merupakan route dari si web dengan bantuan nikic - fast route qt dapat membuat | |
//system route dengan url cantik | |
$app->get('/', function (Request $request, Response $response, array $args) { | |
$response->getBody()->write("Hello, From Slim 3"); | |
return $response; | |
}); | |
//fungsi menjalankan aplikasi slim kita | |
$app->run(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment