{"id":15322827,"url":"https://github.com/msfidelis/silex-api-skeleton","last_synced_at":"2026-01-06T20:47:28.102Z","repository":{"id":92817876,"uuid":"72316065","full_name":"msfidelis/silex-api-skeleton","owner":"msfidelis","description":"API criada utilizando o microframework Silex com o ORM Doctrine no padrão MVC pra construção rápida de API's para MVPs  :rocket: :space_invader: :octocat:","archived":false,"fork":false,"pushed_at":"2017-06-26T01:06:06.000Z","size":85,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-01T21:14:06.435Z","etag":null,"topics":["api","docker","doctrine-orm","php7","silex"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/msfidelis.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-10-30T00:12:08.000Z","updated_at":"2022-02-12T11:00:32.000Z","dependencies_parsed_at":"2023-04-21T16:04:49.972Z","dependency_job_id":null,"html_url":"https://github.com/msfidelis/silex-api-skeleton","commit_stats":{"total_commits":44,"total_committers":4,"mean_commits":11.0,"dds":0.6136363636363636,"last_synced_commit":"e4b8a3254fe06eff5be0ae1bd297a957875a444f"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/msfidelis%2Fsilex-api-skeleton","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/msfidelis%2Fsilex-api-skeleton/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/msfidelis%2Fsilex-api-skeleton/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/msfidelis%2Fsilex-api-skeleton/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/msfidelis","download_url":"https://codeload.github.com/msfidelis/silex-api-skeleton/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245898335,"owners_count":20690466,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api","docker","doctrine-orm","php7","silex"],"created_at":"2024-10-01T09:18:16.753Z","updated_at":"2026-01-06T20:47:28.066Z","avatar_url":"https://github.com/msfidelis.png","language":"PHP","readme":"# Silex PHP MVC - Fast API :rocket: :space_invader: :octocat:\nExemplos de API criada utilizando o microframework Silex com o ORM Doctrine.\nCriei essa paradinha pra não precisar ficar horas configurando o ambiente do Silex sempre que precisar construir uma API simples com PHP. Já ta tudo aí­ :D\n\n* Modifiquei a arquitetura pra utilizar o padrÃ£o MVC na construção de API's de maneira simples e robusta :)\n\n# Docker Stacks :whale:\n\n## PHP7 on Cli\n\nContainers de PHP7 (Servidor Interno) + MySQL - Não recomendado para produção, somente para desenvolvimento e testes\n\n```\n    docker-compose -f docker-compose-cli.yml up\n```\n\n## PHP7-FPM + NGinx\n\nContainers de PHP7 utilizando uma arquitetura FPM + MySQL . - Bom para API's com alta concorrência.\n\n```\n    docker-compose -f docker-compose-nginx.yml up\n```\n\n## PHP7 apacheconf\n\nContainers de PHP7 + Apache + MySQL\n\n```\n    docker-compose -f docker-compose-apache.yml up\n```\n\n# PHP CLI\n\n```\n php -S 0.0.0.0:80 web/\n```\n\n# Apache\n\n## Exemplo do htaccess\n\n``` apacheconf\n\u003cIfModule mod_rewrite.c\u003e\n    Options -MultiViews\n\n    RewriteEngine On\n    #RewriteBase /path/to/app\n    RewriteCond %{REQUEST_FILENAME} !-d\n    RewriteCond %{REQUEST_FILENAME} !-f\n    RewriteRule ^ index.php [QSA,L]\n\u003c/IfModule\u003e\n\n```\n\n## Exemplo do VHOST\n\n``` apacheconf\n\u003cVirtualHost *:80\u003e\n        DocumentRoot \"/Users/fidelis/Sites/Api-Web/web/\"\n        Servername local.apiweb.com\n        DirectoryIndex index.php\n        \u003cDirectory \"/Users/fidelis/Sites/Api-Web/web/\"\u003e\n            AllowOverride All\n            Allow from All\n        \u003c/Directory\u003e\n\u003c/VirtualHost\u003e\n```\n\n# Começando\n\n* Você vai precisar do [composer!](https://getcomposer.org/)\n\n``` bash\n # curl -s -o /usr/local/bin/composer https://getcomposer.org/composer.phar\n # chmod 0755 /usr/local/bin/composer\n```\n\nE na pasta do projeto, onde se encontra nosso arquivinho composer.json:\n\n``` bash\n # composer install\n```\n\n# Testes  \n\nPara rodar os testes, você pode utilizar o PHPunit diretamente ou aproveitar o alias do compose que eu criei\n\n```\n  composer test\n```\n\n\n# Migrations\n\nAdicionei o Doctrine Migrations pra automatizar meus deploys e testes em schemas de bancos de dados.\n\n* Gerar uma nova migration\n\n```\n  php console.php migrations:generate\n\n  # Loading configuration from file: migrations.yml\n  # Generated new migration class to \"/Users/matheus/Workspace/SilexPHP-API-Skeleton/web/src/Migrations/Version20170215004833.php\"\n```\n\n* Rodar as Migrations\n\n```\n  php console.php migrations:migrate\n```\n\n\n\n* Vai precisar ler um poquinho sobre o [Silex PHP](http://silex.sensiolabs.org/doc/master/), esse microframework PHP voltado para construção de API's de forma Ágil\n\n* Leia também sobre o [Doctrine ORM](http://docs.doctrine-project.org/en/latest/) e o [Doctrine Query Builder](http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/reference/query-builder.html). Gastei um tempinho abstraindo as coisas pra deixar um MVC mais amigÃ¡vel pra manipulação de dados mais modular\n\n* Da uma passadinha na documentação do [Twig](http://twig.sensiolabs.org/) também. Esse manipulador de View da dahora pra caramba de tão simples\n\n* Lembrando que o Silex usa vários componentes do [Symfony Framework](https://symfony.com/) . Talvez a documentação te ajude em algum momento.\n\n# CRUD Teste \n\n* Migrations \n\nSerá necessário rodar as migrations já existentes\n\n```\n$ php console.php migrations:migrate\n```\n\n### POST - Create Employee\n\n```bash\n$ curl -H \"Content-type: application/json\" \\\n    -d '{\"name\": \"Matheus Fidelis\", \"age\":\"21\", \"salary\":200}' \\\n    -X POST localhost/employee/ -i \n```\n\n```\nHTTP/1.1 201 Created\nServer: nginx/1.6.2\nContent-Type: application/json\nTransfer-Encoding: chunked\nConnection: keep-alive\nX-Powered-By: PHP/7.0.17\nCache-Control: no-cache, private\nDate: Sat, 13 May 2017 12:03:53 GMT\nX-Symfony-Cache: POST /employee/: pass, invalidate\n\n{\"id\":\"25\",\"name\":\"\\u0027Matheus Fidelis\\u0027\",\"age\":\"21\",\"salary\":\"200\"}\n```\n\n### GET - List all Employees\n\n```bash\n$ curl -H \"Content-type: application/json\" \\\n    -X GET localhost/employee/ -i \n```\n\n```\nHTTP/1.1 200 OK\nServer: nginx/1.6.2\nContent-Type: application/json\nTransfer-Encoding: chunked\nConnection: keep-alive\nX-Powered-By: PHP/7.0.17\nCache-Control: no-cache, private\nDate: Sat, 13 May 2017 12:06:59 GMT\nX-Symfony-Cache: GET /employee/: miss\n\n[{\"id\":\"1\",\"name\":\"\\u0027Matheus Fidelis\\u0027\",\"age\":\"21\",\"salary\":\"200\"},{\"id\":\"2\",\"name\":\"\\u0027Matheus Fidelis\\u0027\",\"age\":\"21\",\"salary\":\"200\"},{\"id\":\"3\",\"name\":\"\\u0027Matheus Fidelis\\u0027\",\"age\":\"21\",\"salary\":\"200\"}]\n```\n\n### GET - List a single Employee\n\n```bash\n$ curl -H \"Content-type: application/json\" \\\n    -X GET localhost/employee/1 -i \n```\n\n```yml\nHTTP/1.1 200 OK\nServer: nginx/1.6.2\nContent-Type: application/json\nTransfer-Encoding: chunked\nConnection: keep-alive\nX-Powered-By: PHP/7.0.17\nCache-Control: no-cache, private\nDate: Sat, 13 May 2017 12:07:24 GMT\nX-Symfony-Cache: GET /employee/1: miss\n\n{\"id\":\"1\",\"name\":\"\\u0027Matheus Fidelis\\u0027\",\"age\":\"21\",\"salary\":\"200\"}\n```\n\n### PUT - Update a employee\n\n```bash\n$ curl -H \"Content-type: application/json\" \\\n    -d '{\"name\": \"Matheus Fidelis - Changed!\", \"age\":\"21\", \"salary\":200}' \\\n    -X PUT localhost/employee/1 -i \n```\n\n```yml\nHTTP/1.1 200 OK\nServer: nginx/1.6.2\nContent-Type: application/json\nTransfer-Encoding: chunked\nConnection: keep-alive\nX-Powered-By: PHP/7.0.17\nCache-Control: no-cache, private\nDate: Sat, 13 May 2017 12:11:53 GMT\nX-Symfony-Cache: PUT /employee/1: pass, invalidate\n\n{\"id\":\"1\",\"name\":\"Matheus Fidelis - Changed!!!\",\"age\":\"21\",\"salary\":\"200\"}\n```\n\n### DELETE - Delete a Employee\n\n```bash\n$ curl -H \"Content-type: application/json\" \\\n    -X DELETE localhost/employee/1 -i \n```\n\n```yml\nHTTP/1.1 204 No Content\nServer: nginx/1.6.2\nContent-Type: text/html; charset=UTF-8\nConnection: keep-alive\nX-Powered-By: PHP/7.0.17\nCache-Control: no-cache, private\nDate: Sat, 13 May 2017 12:15:04 GMT\nX-Symfony-Cache: DELETE /employee/1: pass, invalidate\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmsfidelis%2Fsilex-api-skeleton","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmsfidelis%2Fsilex-api-skeleton","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmsfidelis%2Fsilex-api-skeleton/lists"}