From f39ff0d6c6a7e7882cda4a4d8625985d3e34845f Mon Sep 17 00:00:00 2001 From: Thiago Oliveira Date: Mon, 30 Oct 2017 01:36:04 -0200 Subject: [PATCH] Commit inicial --- .gitignore | 2 + README.md | 68 ++--- application/index.php | 95 +++++++ composer.json | 5 + composer.lock | 648 ++++++++++++++++++++++++++++++++++++++++++ database.sql | 16 ++ 6 files changed, 800 insertions(+), 34 deletions(-) create mode 100644 .gitignore create mode 100644 application/index.php create mode 100644 composer.json create mode 100644 composer.lock create mode 100644 database.sql diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..c3ddeb83 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +vendor/ +.idea/ \ No newline at end of file diff --git a/README.md b/README.md index 8fb16649..4db93027 100644 --- a/README.md +++ b/README.md @@ -1,34 +1,34 @@ -# A tarefa -Sua tarefa consiste em desenvolver uma API RESTful para manipular um determinado recurso. Deverá ser utilizado o framework Silex. - -# Requisitos -A escolha do recurso deverá ser feita pelo desenvolvedor, atendendo apenas os requisitos mínimos abaixo: - -* Deverá conter um ID -* Deverá conter pelo menos quatro propriedades (exemplos: nome, email, etc.) -* Deverá conter campos que armazenem as datas de criação e alteração do recurso - -A API deverá atender às seguintes exigências: - -* Listagem de todos os recursos -* Busca de um recurso pelo ID -* Criação de um novo recurso -* Alteração de um recurso existente -* Exclusão de um recurso -* Aceitar e retornar apenas JSON -* Deverá possuir algum método de autenticação para utilização de seus endpoints - -# Ferramentas -* PHP -* Banco de dados MySQL -* Framework Silex - -# Fluxo de desenvolvimento -1. Faça um fork deste repositório -2. Crie uma nova branch e nomeie-a com seu usuário do Github -3. Quando o desenvolvimento estiver concluído, faça um pull request - -# Padrões de nomenclatura -1. Código fonte, nome do banco de dados, tabelas e campos devem estar em inglês - -**Inclua no seu commit todos os arquivos necessários para que possamos testar o código.** +**Ambiente utilizado** +* PHP 7.0.4 +* MySQL 5.7.11 + +1. Criar o bando de dados rodando o script _`database.sql`_ +2. Acessar a raiz do projeto pelo terminal e digitar o comando `composer install` +3. Ainda no terminal digitar o comando `php -S localhost:80 -t application/` + +**Autenticação** +``` +curl -X POST http://localhost:80/login -H 'content-type: application/json' -d '{"user":"admin", "password":"123"}' +``` +**Observação:** Salvar o token retornado para as demais requisições + +**Listar todos** +``` +curl -X GET http://localhost:80/livros -H 'cache-control: no-cache' -H 'content-type: application/json' -H 'x-access-token: {token}' +``` +**Listar um** +``` +curl -X GET http://localhost:80/livro/{id} -H 'cache-control: no-cache' -H 'content-type: application/json' -H 'x-access-token: {token}' +``` +**Inserir** +``` +curl -X POST http://localhost:80/livro -H 'cache-control: no-cache' -H 'content-type: application/json' -H 'x-access-token: {token}' -d '{"title": "{valor}", "author": "{valor}", "publishing_company": "{valor}", "pages": {valor}}' +``` +**Alterar** +``` +curl -X PUT http://localhost:80/livro/{id} -H 'cache-control: no-cache' -H 'content-type: application/json' -H 'x-access-token: {token}' -d '{"title": "{valor}", "author": "{valor}", "publishing_company": "{valor}", "pages": {valor}}' +``` +**Deletar** +``` +curl -X DELETE http://localhost:80/livro/{id} -H 'cache-control: no-cache' -H 'content-type: application/json' -H 'x-access-token: {token}' +``` \ No newline at end of file diff --git a/application/index.php b/application/index.php new file mode 100644 index 00000000..fc21a196 --- /dev/null +++ b/application/index.php @@ -0,0 +1,95 @@ +getMessage(); +} + +$app->before(function(Request $request) use ($app) { + if($request->isMethod('GET')) + return; + if (0 === strpos($request->headers->get('Content-Type'), 'application/json')) { + $data = json_decode($request->getContent(), true); + $request->request->replace(is_array($data) ? $data : array()); + } else { + return $app->json(array('error' => true, 'message' => 'Cabeçalho somente com Content-Type: application/json'), 404); + } +}); + +$app->before(function(Request $request) use ($app) { + echo $request->getPathInfo(); + if($request->getPathInfo() == '/login') + return; + $token = $request->headers->get('x-access-token'); + if(!$token) + return $app->json(array('error' => true, 'message' => 'Não a token'), 403); + if(md5('admin123') != $token) + return $app->json(array('error' => true, 'message' => 'Token inválido'), 403); +}); + +// POST /login +$app->post('/login', function(Request $request) use ($app) { + if($request->get('user') == 'admin' && $request->get('password') == '123') + return $app->json(array('error' => false, 'message' => null, 'content' => array('token' => md5('admin123')))); + else + return $app->json(array('error' => true, 'message' => 'Dado(s) incorreto(s).', 'content' => null), 401); +}); + +// GET /livros +$app->get('/livros', function () use ($app, $pdo) { + $statement = $pdo->prepare('select id, title, author, publishing_company, pages, inserted_in, changed_in from books'); + $statement->execute(); + $books = $statement->fetchAll(PDO::FETCH_ASSOC); + return $app->json(array('error' => false, 'message' => null, 'content' => array('books' => $books))); +}); + +// GET /livro/{id} +$app->get('/livro/{id}', function ($id) use ($app, $pdo) { + $statement = $pdo->prepare('select id, title, author, publishing_company, pages, inserted_in, changed_in from books where id=?'); + $statement->execute([$id]); + $book = $statement->fetchAll(PDO::FETCH_ASSOC); + if(empty($book)) + return $app->json(array('error' => true, 'message' => 'Livro não encontrado.', 'content' => null), 404); + return $app->json(array('error' => false, 'message' => null, 'content' => array('book' => $book))); +})->assert('id', '\d+'); + +// POST /livro +$app->post('/livro', function(Request $request) use ($app, $pdo) { + $data = json_decode($request->getContent(), true); + $statement = $pdo->prepare('insert into books (title, author, publishing_company, pages, inserted_in) VALUES(:title, :author, :publishing_company, :pages, now())'); + $statement->execute($data); + $id = $pdo->lastInsertId(); + if($id > 0) + return $app->json(array('error' => false, 'message' => 'Livro inserido', 'content' => array('id' => $id)), 201); + return $app->json(array('error' => true, 'message' => 'Livro não inserido', 'content' => null), 404); +}); + +// PUT /livro/{id} +$app->put('/livro/{id}', function(Request $request, $id) use ($app, $pdo) { + $data = json_decode($request->getContent(), true); + $data['id'] = $id; + $statement = $pdo->prepare('update books set title=:title, author=:author, publishing_company=:publishing_company, pages=:pages, changed_in=now() where id=:id'); + $statement->execute($data); + if($statement->rowCount() < 1) + return $app->json(array('error' => true, 'message' => 'Livro não encontrado', 'content' => null), 404); + return $app->json(array('error' => false, 'message' => 'Livro alterado', 'content' => array('book' => $data))); +})->assert('id', '\d+'); + +// DELETE /livro/{id} +$app->delete('/livro/{id}', function($id) use ($app, $pdo) { + $statement = $pdo->prepare('delete from books where id = ?'); + $statement->execute([$id]); + if($statement->rowCount() < 1) + return $app->json(array('error' => true, 'message' => 'Livro não encontrado', 'content' => null), 404); + return $app->json(array('error' => false, 'message' => 'Livro deletado', 'content' => null)); +})->assert('id', '\d+'); + +$app->run(); \ No newline at end of file diff --git a/composer.json b/composer.json new file mode 100644 index 00000000..be665ae6 --- /dev/null +++ b/composer.json @@ -0,0 +1,5 @@ +{ + "require": { + "silex/silex": "~2.0" + } +} diff --git a/composer.lock b/composer.lock new file mode 100644 index 00000000..28398823 --- /dev/null +++ b/composer.lock @@ -0,0 +1,648 @@ +{ + "_readme": [ + "This file locks the dependencies of your project to a known state", + "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", + "This file is @generated automatically" + ], + "content-hash": "85677501dca45c0b473c524c2f1a82b0", + "packages": [ + { + "name": "pimple/pimple", + "version": "v3.2.2", + "source": { + "type": "git", + "url": "https://github.com/silexphp/Pimple.git", + "reference": "4d45fb62d96418396ec58ba76e6f065bca16e10a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/silexphp/Pimple/zipball/4d45fb62d96418396ec58ba76e6f065bca16e10a", + "reference": "4d45fb62d96418396ec58ba76e6f065bca16e10a", + "shasum": "" + }, + "require": { + "php": ">=5.3.0", + "psr/container": "^1.0" + }, + "require-dev": { + "symfony/phpunit-bridge": "^3.2" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.2.x-dev" + } + }, + "autoload": { + "psr-0": { + "Pimple": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + } + ], + "description": "Pimple, a simple Dependency Injection Container", + "homepage": "http://pimple.sensiolabs.org", + "keywords": [ + "container", + "dependency injection" + ], + "time": "2017-07-23T07:32:15+00:00" + }, + { + "name": "psr/container", + "version": "1.0.0", + "source": { + "type": "git", + "url": "https://github.com/php-fig/container.git", + "reference": "b7ce3b176482dbbc1245ebf52b181af44c2cf55f" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/container/zipball/b7ce3b176482dbbc1245ebf52b181af44c2cf55f", + "reference": "b7ce3b176482dbbc1245ebf52b181af44c2cf55f", + "shasum": "" + }, + "require": { + "php": ">=5.3.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\Container\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "http://www.php-fig.org/" + } + ], + "description": "Common Container Interface (PHP FIG PSR-11)", + "homepage": "https://github.com/php-fig/container", + "keywords": [ + "PSR-11", + "container", + "container-interface", + "container-interop", + "psr" + ], + "time": "2017-02-14T16:28:37+00:00" + }, + { + "name": "psr/log", + "version": "1.0.2", + "source": { + "type": "git", + "url": "https://github.com/php-fig/log.git", + "reference": "4ebe3a8bf773a19edfe0a84b6585ba3d401b724d" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/log/zipball/4ebe3a8bf773a19edfe0a84b6585ba3d401b724d", + "reference": "4ebe3a8bf773a19edfe0a84b6585ba3d401b724d", + "shasum": "" + }, + "require": { + "php": ">=5.3.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\Log\\": "Psr/Log/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "http://www.php-fig.org/" + } + ], + "description": "Common interface for logging libraries", + "homepage": "https://github.com/php-fig/log", + "keywords": [ + "log", + "psr", + "psr-3" + ], + "time": "2016-10-10T12:19:37+00:00" + }, + { + "name": "silex/silex", + "version": "v2.2.0", + "source": { + "type": "git", + "url": "https://github.com/silexphp/Silex.git", + "reference": "ec7d5b5334465414952d4b2e935e73bd085dbbbb" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/silexphp/Silex/zipball/ec7d5b5334465414952d4b2e935e73bd085dbbbb", + "reference": "ec7d5b5334465414952d4b2e935e73bd085dbbbb", + "shasum": "" + }, + "require": { + "php": ">=5.5.9", + "pimple/pimple": "~3.0", + "symfony/event-dispatcher": "~2.8|^3.0", + "symfony/http-foundation": "~2.8|^3.0", + "symfony/http-kernel": "~2.8|^3.0", + "symfony/routing": "~2.8|^3.0" + }, + "conflict": { + "phpunit/phpunit": "<4.8.35 || >= 5.0, <5.4.3" + }, + "replace": { + "silex/api": "self.version", + "silex/providers": "self.version" + }, + "require-dev": { + "doctrine/dbal": "~2.2", + "monolog/monolog": "^1.4.1", + "swiftmailer/swiftmailer": "~5", + "symfony/asset": "~2.8|^3.0", + "symfony/browser-kit": "~2.8|^3.0", + "symfony/config": "~2.8|^3.0", + "symfony/css-selector": "~2.8|^3.0", + "symfony/debug": "~2.8|^3.0", + "symfony/doctrine-bridge": "~2.8|^3.0", + "symfony/dom-crawler": "~2.8|^3.0", + "symfony/expression-language": "~2.8|^3.0", + "symfony/finder": "~2.8|^3.0", + "symfony/form": "~2.8|^3.0", + "symfony/intl": "~2.8|^3.0", + "symfony/monolog-bridge": "~2.8|^3.0", + "symfony/options-resolver": "~2.8|^3.0", + "symfony/phpunit-bridge": "^3.2", + "symfony/process": "~2.8|^3.0", + "symfony/security": "~2.8|^3.0", + "symfony/serializer": "~2.8|^3.0", + "symfony/translation": "~2.8|^3.0", + "symfony/twig-bridge": "~2.8|^3.0", + "symfony/validator": "~2.8|^3.0", + "symfony/var-dumper": "~2.8|^3.0", + "symfony/web-link": "^3.3", + "twig/twig": "~1.28|~2.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.2.x-dev" + } + }, + "autoload": { + "psr-4": { + "Silex\\": "src/Silex" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Igor Wiedler", + "email": "igor@wiedler.ch" + } + ], + "description": "The PHP micro-framework based on the Symfony Components", + "homepage": "http://silex.sensiolabs.org", + "keywords": [ + "microframework" + ], + "time": "2017-07-23T07:40:14+00:00" + }, + { + "name": "symfony/debug", + "version": "v3.3.6", + "source": { + "type": "git", + "url": "https://github.com/symfony/debug.git", + "reference": "7c13ae8ce1e2adbbd574fc39de7be498e1284e13" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/debug/zipball/7c13ae8ce1e2adbbd574fc39de7be498e1284e13", + "reference": "7c13ae8ce1e2adbbd574fc39de7be498e1284e13", + "shasum": "" + }, + "require": { + "php": ">=5.5.9", + "psr/log": "~1.0" + }, + "conflict": { + "symfony/http-kernel": ">=2.3,<2.3.24|~2.4.0|>=2.5,<2.5.9|>=2.6,<2.6.2" + }, + "require-dev": { + "symfony/http-kernel": "~2.8|~3.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.3-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Component\\Debug\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony Debug Component", + "homepage": "https://symfony.com", + "time": "2017-07-28T15:27:31+00:00" + }, + { + "name": "symfony/event-dispatcher", + "version": "v3.3.6", + "source": { + "type": "git", + "url": "https://github.com/symfony/event-dispatcher.git", + "reference": "67535f1e3fd662bdc68d7ba317c93eecd973617e" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/67535f1e3fd662bdc68d7ba317c93eecd973617e", + "reference": "67535f1e3fd662bdc68d7ba317c93eecd973617e", + "shasum": "" + }, + "require": { + "php": ">=5.5.9" + }, + "conflict": { + "symfony/dependency-injection": "<3.3" + }, + "require-dev": { + "psr/log": "~1.0", + "symfony/config": "~2.8|~3.0", + "symfony/dependency-injection": "~3.3", + "symfony/expression-language": "~2.8|~3.0", + "symfony/stopwatch": "~2.8|~3.0" + }, + "suggest": { + "symfony/dependency-injection": "", + "symfony/http-kernel": "" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.3-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Component\\EventDispatcher\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony EventDispatcher Component", + "homepage": "https://symfony.com", + "time": "2017-06-09T14:53:08+00:00" + }, + { + "name": "symfony/http-foundation", + "version": "v3.3.6", + "source": { + "type": "git", + "url": "https://github.com/symfony/http-foundation.git", + "reference": "49e8cd2d59a7aa9bfab19e46de680c76e500a031" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/http-foundation/zipball/49e8cd2d59a7aa9bfab19e46de680c76e500a031", + "reference": "49e8cd2d59a7aa9bfab19e46de680c76e500a031", + "shasum": "" + }, + "require": { + "php": ">=5.5.9", + "symfony/polyfill-mbstring": "~1.1" + }, + "require-dev": { + "symfony/expression-language": "~2.8|~3.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.3-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Component\\HttpFoundation\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony HttpFoundation Component", + "homepage": "https://symfony.com", + "time": "2017-07-21T11:04:46+00:00" + }, + { + "name": "symfony/http-kernel", + "version": "v3.3.6", + "source": { + "type": "git", + "url": "https://github.com/symfony/http-kernel.git", + "reference": "db10d05f1d95e4168e638db7a81c79616f568ea5" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/http-kernel/zipball/db10d05f1d95e4168e638db7a81c79616f568ea5", + "reference": "db10d05f1d95e4168e638db7a81c79616f568ea5", + "shasum": "" + }, + "require": { + "php": ">=5.5.9", + "psr/log": "~1.0", + "symfony/debug": "~2.8|~3.0", + "symfony/event-dispatcher": "~2.8|~3.0", + "symfony/http-foundation": "~3.3" + }, + "conflict": { + "symfony/config": "<2.8", + "symfony/dependency-injection": "<3.3", + "symfony/var-dumper": "<3.3", + "twig/twig": "<1.34|<2.4,>=2" + }, + "require-dev": { + "psr/cache": "~1.0", + "symfony/browser-kit": "~2.8|~3.0", + "symfony/class-loader": "~2.8|~3.0", + "symfony/config": "~2.8|~3.0", + "symfony/console": "~2.8|~3.0", + "symfony/css-selector": "~2.8|~3.0", + "symfony/dependency-injection": "~3.3", + "symfony/dom-crawler": "~2.8|~3.0", + "symfony/expression-language": "~2.8|~3.0", + "symfony/finder": "~2.8|~3.0", + "symfony/process": "~2.8|~3.0", + "symfony/routing": "~2.8|~3.0", + "symfony/stopwatch": "~2.8|~3.0", + "symfony/templating": "~2.8|~3.0", + "symfony/translation": "~2.8|~3.0", + "symfony/var-dumper": "~3.3" + }, + "suggest": { + "symfony/browser-kit": "", + "symfony/class-loader": "", + "symfony/config": "", + "symfony/console": "", + "symfony/dependency-injection": "", + "symfony/finder": "", + "symfony/var-dumper": "" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.3-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Component\\HttpKernel\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony HttpKernel Component", + "homepage": "https://symfony.com", + "time": "2017-08-01T10:25:59+00:00" + }, + { + "name": "symfony/polyfill-mbstring", + "version": "v1.6.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-mbstring.git", + "reference": "2ec8b39c38cb16674bbf3fea2b6ce5bf117e1296" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/2ec8b39c38cb16674bbf3fea2b6ce5bf117e1296", + "reference": "2ec8b39c38cb16674bbf3fea2b6ce5bf117e1296", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "suggest": { + "ext-mbstring": "For best performance" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.6-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Polyfill\\Mbstring\\": "" + }, + "files": [ + "bootstrap.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill for the Mbstring extension", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "mbstring", + "polyfill", + "portable", + "shim" + ], + "time": "2017-10-11T12:05:26+00:00" + }, + { + "name": "symfony/routing", + "version": "v3.3.6", + "source": { + "type": "git", + "url": "https://github.com/symfony/routing.git", + "reference": "4aee1a917fd4859ff8b51b9fd1dfb790a5ecfa26" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/routing/zipball/4aee1a917fd4859ff8b51b9fd1dfb790a5ecfa26", + "reference": "4aee1a917fd4859ff8b51b9fd1dfb790a5ecfa26", + "shasum": "" + }, + "require": { + "php": ">=5.5.9" + }, + "conflict": { + "symfony/config": "<2.8", + "symfony/dependency-injection": "<3.3", + "symfony/yaml": "<3.3" + }, + "require-dev": { + "doctrine/annotations": "~1.0", + "doctrine/common": "~2.2", + "psr/log": "~1.0", + "symfony/config": "~2.8|~3.0", + "symfony/dependency-injection": "~3.3", + "symfony/expression-language": "~2.8|~3.0", + "symfony/http-foundation": "~2.8|~3.0", + "symfony/yaml": "~3.3" + }, + "suggest": { + "doctrine/annotations": "For using the annotation loader", + "symfony/config": "For using the all-in-one router or any loader", + "symfony/dependency-injection": "For loading routes from a service", + "symfony/expression-language": "For using expression matching", + "symfony/http-foundation": "For using a Symfony Request object", + "symfony/yaml": "For using the YAML loader" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.3-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Component\\Routing\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony Routing Component", + "homepage": "https://symfony.com", + "keywords": [ + "router", + "routing", + "uri", + "url" + ], + "time": "2017-07-21T17:43:13+00:00" + } + ], + "packages-dev": [], + "aliases": [], + "minimum-stability": "stable", + "stability-flags": [], + "prefer-stable": false, + "prefer-lowest": false, + "platform": [], + "platform-dev": [] +} diff --git a/database.sql b/database.sql new file mode 100644 index 00000000..dceec3ab --- /dev/null +++ b/database.sql @@ -0,0 +1,16 @@ +create database `test_thideoli`; + +create table `test_thideoli`.`books` ( + `id` int not null auto_increment, + `title` varchar(255) not null, + `author` varchar(255) not null, + `publishing_company` varchar(255) not null, + `pages` varchar(255) not null, + `inserted_in` datetime not null, + `changed_in` datetime null, + primary key (`id`) +); + +use `test_thideoli`; +insert into `books` (`title`, `author`, `publishing_company`, `pages`, `inserted_in`) + VALUES('Como ser um programador melhor', 'Pete Goodliffe', 'Novatec', 384, now()); \ No newline at end of file