Design pattern for WebApi project

0

I need to create a project with WebAPI to consume some procedures from a remote SQL database, for example: sp_retornaProdutos(1) transforming this to /produtos/1 and returning the result in JSON .

I thought about creating models and response , like this:

// Model para envio de parâmetros
public class ProdutoReq
{
    int id;
}

// Model para retorno do resultado
public class ProdutoRes
{
    int id;
    string nome;
    string descricao;
    decimal preco;
}

I would like to know how you indicate to build this application, which design pattern to use?

    
asked by anonymous 30.06.2015 / 02:52

1 answer

0

You can use the Slim Framework it is a micro framework developed in php .

Example usage:


$app = new \Slim\Slim();
$app->get('/hello/:name', function ($name) {
    echo "Hello, $name";
});

$app->run();

Where this echo you can put your SQL to give a return. when calling api, more documentation at: Docs.Slim

and a how to Learn to to use RESTful with PHP and Slim Framework

    
30.06.2015 / 13:57