update silex sample code location

This commit is contained in:
William Cheng 2015-06-19 02:37:08 +08:00
parent 0b0325b8af
commit f957471509
4 changed files with 204 additions and 0 deletions

View File

@ -0,0 +1,5 @@
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?_url=/$1 [QSA,L]
</IfModule>

View File

@ -0,0 +1,10 @@
# Swagger generated server
## Overview
This server was generated by the [swagger-codegen](https://github.com/swagger-api/swagger-codegen) project. By using the
[swagger-spec](https://github.com/swagger-api/swagger-core/wiki) from a remote server, you can easily generate a server stub. This
is an example of building a PHP server.
This example uses the [Silex](http://silex.sensiolabs.org/) micro-framework. To see how to make this your own, please take a look at the template here:
[TEMPLATES](https://github.com/swagger-api/swagger-codegen/tree/master/modules/swagger-codegen/src/main/resources/silex/)

View File

@ -0,0 +1,5 @@
{
"require": {
"silex/silex": "~1.2"
}
}

View File

@ -0,0 +1,184 @@
<?php
require_once __DIR__ . '/vendor/autoload.php';
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Silex\Application;
$app = new Silex\Application();
$app->POST('/user', function(Application $app, Request $request) {
return new Response('How about implementing createUser as a POST method ?');
});
$app->POST('/user/createWithArray', function(Application $app, Request $request) {
return new Response('How about implementing createUsersWithArrayInput as a POST method ?');
});
$app->POST('/user/createWithList', function(Application $app, Request $request) {
return new Response('How about implementing createUsersWithListInput as a POST method ?');
});
$app->GET('/user/login', function(Application $app, Request $request) {
$username = $request->get('username'); $password = $request->get('password');
return new Response('How about implementing loginUser as a GET method ?');
});
$app->GET('/user/logout', function(Application $app, Request $request) {
return new Response('How about implementing logoutUser as a GET method ?');
});
$app->GET('/user/{username}', function(Application $app, Request $request, $username) {
return new Response('How about implementing getUserByName as a GET method ?');
});
$app->PUT('/user/{username}', function(Application $app, Request $request, $username) {
return new Response('How about implementing updateUser as a PUT method ?');
});
$app->DELETE('/user/{username}', function(Application $app, Request $request, $username) {
return new Response('How about implementing deleteUser as a DELETE method ?');
});
$app->PUT('/pet', function(Application $app, Request $request) {
return new Response('How about implementing updatePet as a PUT method ?');
});
$app->POST('/pet', function(Application $app, Request $request) {
return new Response('How about implementing addPet as a POST method ?');
});
$app->GET('/pet/findByStatus', function(Application $app, Request $request) {
$status = $request->get('status');
return new Response('How about implementing findPetsByStatus as a GET method ?');
});
$app->GET('/pet/findByTags', function(Application $app, Request $request) {
$tags = $request->get('tags');
return new Response('How about implementing findPetsByTags as a GET method ?');
});
$app->GET('/pet/{petId}', function(Application $app, Request $request, $pet_id) {
return new Response('How about implementing getPetById as a GET method ?');
});
$app->POST('/pet/{petId}', function(Application $app, Request $request, $pet_id) {
$name = $request->get('name'); $status = $request->get('status');
return new Response('How about implementing updatePetWithForm as a POST method ?');
});
$app->DELETE('/pet/{petId}', function(Application $app, Request $request, $pet_id) {
return new Response('How about implementing deletePet as a DELETE method ?');
});
$app->POST('/pet/{petId}/uploadImage', function(Application $app, Request $request, $pet_id) {
$additional_metadata = $request->get('additional_metadata'); $file = $request->get('file');
return new Response('How about implementing uploadFile as a POST method ?');
});
$app->GET('/store/inventory', function(Application $app, Request $request) {
return new Response('How about implementing getInventory as a GET method ?');
});
$app->POST('/store/order', function(Application $app, Request $request) {
return new Response('How about implementing placeOrder as a POST method ?');
});
$app->GET('/store/order/{orderId}', function(Application $app, Request $request, $order_id) {
return new Response('How about implementing getOrderById as a GET method ?');
});
$app->DELETE('/store/order/{orderId}', function(Application $app, Request $request, $order_id) {
return new Response('How about implementing deleteOrder as a DELETE method ?');
});
$app->run();