コード例 #1
0
ファイル: album.php プロジェクト: ronenguttman/MusicStore
<?php

require_once dirname(__FILE__) . '/../RESTControllers/AlbumRESTController.php';
$album = new AlbumRESTController();
// Get all the albums
$app->get('/album', function () use($app, $album) {
    $albums = $album->getAllAlbums();
    if ($albums["error"]) {
        $app->response()->status(400);
        $app->response()->header('X-Status-Reason', $albums["msg"]);
    }
    echo json_encode($albums);
});
// Get specific album
$app->get('/album/:id', function ($id) {
});
// Get specific album
$app->get('/album/search/:term', function ($term) use($album) {
    $response = $album->searchAlbums($term);
    $code = $response["code"];
    if ($code != 200) {
        $app->response()->status($code);
        $app->response()->header('X-Status-Reason', $response["error"]);
    } else {
        echo json_encode($response["result"]);
    }
});
// Insert new album, get the RAW data
$app->post('/album/', function () {
    global $app;
    // This is the RAW Data (Payload) we need to handle
コード例 #2
0
ファイル: index.php プロジェクト: VovaMukovozov/finalProject
<?php

require 'Slim/Slim.php';
require_once '../Controllers/AlbumRESTController.php';
require_once '../Controllers/UserRESTController.php';
require_once '../Controllers/GenreRESTController.php';
require_once '../Controllers/SongRESTController.php';
require_once '../Controllers/SearchRESTController.php';
require_once '../Controllers/OrderRESTController.php';
\Slim\Slim::registerAutoloader();
$app = new \Slim\Slim();
$song = new SongRESTController();
$album = new AlbumRESTController();
$newUser = new UserRESTController();
$login = new UserRESTController();
$genre = new GenreRESTController();
$search = new SearchRESTController();
$order = new OrderRESTController();
// GET route
$app->get('/', function () {
    echo json_encode(array("error" => 1, "msg" => "No method selected"));
});
$app->get('/songs', function () use($app, $song) {
    $request = $app->request->getBody();
    $songs = $song->getSong($request);
    echo $songs;
});
$app->get('/categories', function () use($genre) {
    $genres = $genre->getAllGenres();
    echo $genres;
});