Ajout des sources
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
parent
5cfefd19ef
commit
0c2f54565d
@ -0,0 +1 @@
|
||||
vendor/*
|
@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
$config=[
|
||||
'determineRouteBeforeAppMiddleware' => false,
|
||||
'displayErrorDetails' => true,
|
||||
'db' => [
|
||||
'driver' => 'mysql',
|
||||
'host' => 'localhost',
|
||||
'database' => 'database',
|
||||
'username' => 'user',
|
||||
'password' => 'password',
|
||||
'charset' => 'utf8',
|
||||
'collation' => 'utf8_unicode_ci',
|
||||
'prefix' => ''
|
||||
]
|
||||
];
|
@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
$container = $app->getContainer();
|
||||
|
||||
$container['db'] = function ($container) {
|
||||
$capsule = new \Illuminate\Database\Capsule\Manager;
|
||||
$capsule->addConnection($container['settings']['db']);
|
||||
|
||||
$capsule->setAsGlobal();
|
||||
$capsule->bootEloquent();
|
||||
|
||||
return $capsule;
|
||||
};
|
@ -0,0 +1,11 @@
|
||||
{
|
||||
"require": {
|
||||
"slim/slim": "3.*",
|
||||
"illuminate/database": "~5.1"
|
||||
},
|
||||
"config": {
|
||||
"allow-plugins": {
|
||||
"kylekatarnls/update-helper": true
|
||||
}
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,72 @@
|
||||
<?php
|
||||
use \Psr\Http\Message\ServerRequestInterface as Request;
|
||||
use \Psr\Http\Message\ResponseInterface as Response;
|
||||
|
||||
require '../vendor/autoload.php';
|
||||
require '../app/config.php';
|
||||
|
||||
|
||||
|
||||
|
||||
// App instantiation
|
||||
$app = new \Slim\App(['settings' => $config]);
|
||||
require '../app/dependencies.php';
|
||||
|
||||
|
||||
|
||||
|
||||
// Routes
|
||||
$app->get('/hello/{name}', function (Request $request, Response $response, array $args) {
|
||||
$name = $args['name'];
|
||||
$response->getBody()->write("Hello, $name");
|
||||
|
||||
return $response;
|
||||
});
|
||||
|
||||
$app->get('/users/{id}', function (Request $request, Response $response, array $args) {
|
||||
$res="Get infos of user ".$args['id'];
|
||||
$response->getBody()->write($res);
|
||||
|
||||
return $response;
|
||||
});
|
||||
|
||||
$app->post('/users/{id}', function (Request $request, Response $response, array $args) {
|
||||
$res="Add user ".$args['id'];
|
||||
$response->getBody()->write($res);
|
||||
|
||||
return $response;
|
||||
});
|
||||
|
||||
$app->put('/users/{id}', function (Request $request, Response $response, array $args) {
|
||||
$res="Update infos of user ".$args['id'];
|
||||
$response->getBody()->write($res);
|
||||
|
||||
return $response;
|
||||
});
|
||||
|
||||
$app->delete('/users/{id}', function (Request $request, Response $response, array $args) {
|
||||
$res="Delete user ".$args['id'];
|
||||
$response->getBody()->write($res);
|
||||
|
||||
return $response;
|
||||
});
|
||||
|
||||
$app->post('/user/{id}/like', function (Request $request, Response $response, array $args) {
|
||||
$res="User ".$args['id']." liked ".$args['liked'];
|
||||
$response->getBody()->write($res);
|
||||
|
||||
return $response;
|
||||
});
|
||||
|
||||
$app->post('/users/{id}/preferences', function (Request $request, Response $response, array $args) {
|
||||
$res="User ".$args['id']." add music ".$args['music']." to his preferences for category ".$args['categ'];
|
||||
$response->getBody()->write($res);
|
||||
|
||||
return $response;
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
// Run
|
||||
$app->run();
|
Loading…
Reference in new issue