{"id":37364952,"url":"https://github.com/demartis/symfony5-rest-api","last_synced_at":"2026-01-16T04:50:08.499Z","repository":{"id":37528120,"uuid":"251282420","full_name":"demartis/symfony5-rest-api","owner":"demartis","description":"API REST skeleton with Symfony 5, following best practices and implementing clean architecture.","archived":false,"fork":false,"pushed_at":"2024-04-20T16:57:17.000Z","size":167,"stargazers_count":43,"open_issues_count":0,"forks_count":25,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-04-20T18:11:34.504Z","etag":null,"topics":["api","docker","docker-compose","fosrestbundle","hateoas","json-api","php","rest","rest-api","symfony","symfony5","travis"],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/demartis.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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}},"created_at":"2020-03-30T11:18:51.000Z","updated_at":"2024-04-20T16:43:43.000Z","dependencies_parsed_at":"2024-04-20T17:38:17.869Z","dependency_job_id":"d8e2c7b0-69d9-4940-a2ae-391e0afe09b1","html_url":"https://github.com/demartis/symfony5-rest-api","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/demartis/symfony5-rest-api","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/demartis%2Fsymfony5-rest-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/demartis%2Fsymfony5-rest-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/demartis%2Fsymfony5-rest-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/demartis%2Fsymfony5-rest-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/demartis","download_url":"https://codeload.github.com/demartis/symfony5-rest-api/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/demartis%2Fsymfony5-rest-api/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28477210,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-16T03:13:13.607Z","status":"ssl_error","status_checked_at":"2026-01-16T03:11:47.863Z","response_time":107,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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","docker-compose","fosrestbundle","hateoas","json-api","php","rest","rest-api","symfony","symfony5","travis"],"created_at":"2026-01-16T04:50:08.441Z","updated_at":"2026-01-16T04:50:08.485Z","avatar_url":"https://github.com/demartis.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Symfony 5 REST API skeleton\n\nSymfony 5 + FOSRestBundle + JSON Standard responses + working example\n\n![GitHub last commit](https://img.shields.io/github/last-commit/demartis/symfony5-rest-api.svg)\n![GitHub repo size in bytes](https://img.shields.io/github/repo-size/demartis/symfony5-rest-api.svg)\n![GitHub language count](https://img.shields.io/github/languages/count/demartis/symfony5-rest-api.svg)\n![GitHub top language](https://img.shields.io/github/languages/top/demartis/symfony5-rest-api)\n![GitHub](https://img.shields.io/github/license/demartis/symfony5-rest-api)\n[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Fdemartis%2Fsymfony5-rest-api.svg?type=shield)](https://app.fossa.io/projects/git%2Bgithub.com%2Fdemartis%2Fsymfony5-rest-api?ref=badge_shield)\n\n--------------------------------------\n\n⚠️ PHP 8.x required. If your server is still running PHP 7.x switch to [php7](https://github.com/demartis/symfony5-rest-api/tree/php7) branch.\n\n--------------------------------------\n\n## Table of Contents\n+ [About](#about)\n+ [Getting Started](#getting_started)\n+ [JTTP](#jttp)\n+ [Contributing](#contributing)\n+ [License](#license)\n\n\n\n## About \u003ca name = \"about\"\u003e\u003c/a\u003e\nSymfony 5 skeleton to build REST APIs, inclusive of:\n\n- *FOSRestBundle* (friendsofsymfony/rest-bundle) to simplify the entire process\n- *Hateoas Bundle* (willdurand/hateoas-bundle) that specifies relation types for Web links\n- *Doctrine*\n\n\nThis project is compliant with:\n- [Symfony Best Practices](https://symfony.com/doc/5.4/best_practices.html)\n- [HATEOAS](https://restfulapi.net/hateoas/), [RFC5988 (web links)](https://tools.ietf.org/html/rfc5988), [JSON HAL Model](http://stateless.co/hal_specification.html)\n- [JTTP](https://github.com/demartis/jttp)\n- URIs versioning\n\n\n## Getting Started \u003ca name = \"getting_started\"\u003e\u003c/a\u003e\n\nThese instructions will get you a copy of the project up and running on your local machine \nfor development and testing purposes. \n\n### Prerequisites\n\nWhat things you need to install the software and how to install them.\n- PHP 8.x. For PHP 7 (7.2.5+) use branch `php7`\n- [composer](https://getcomposer.org/download/)\n- [symfony](https://symfony.com/doc/5.4/setup.html)\n- docker (optional)\n\n### Installing\n\n```bash\ngit clone https://github.com/demartis/symfony5-rest-api/\ncd symfony5-rest-api\ncp .env.dist .env\n## edit .env if needed\ncomposer install\nsymfony server:start\n```\n### Installing (alternative with Docker)\n\n```bash\ngit clone https://github.com/demartis/symfony5-rest-api/\ncd symfony5-rest-api\ncp .env.dist .env\n## edit .env if needed\ndocker-compose build\ndocker-compose up\n```\n\n\n### Running the example\n\n#### Install database\n```bash\nphp bin/console doctrine:database:create\nphp bin/console doctrine:migrations:migrate\n```\n\n#### Run local server with Symfony app\n```bash\nsymfony server:start\n```\n\n#### Get with Curl\n\n```bash\ncurl -H 'content-type: application/json' -v -X GET http://127.0.0.1:8000/v1/books\ncurl -H 'content-type: application/json' -v -X GET http://127.0.0.1:8000/v1/books/2 \n```\n\n\n\n## JTTP: Coherent output formats \u003ca name = \"jttp\"\u003e\u003c/a\u003e\n[JTTP](https://github.com/demartis/jttp) is the default protocol \n\nGeneral JTTP output format:\n\n```json\n{\n    \"status\": \"success|error\",\n    \"code\": \"HTTP status code\",\n    \"message\": \"HTTP status message\",\n    \"data|error\": {\n        \"your data\": \"data or error field only in case of success or error\"\n    }\n}\n```\n\nExample - GET resource: GET /v1/books/1\n```json\n{\n    \"status\": \"success\",\n    \"code\": 200,\n    \"message\": \"OK\",\n    \"data\": {\n        \"id\": 1,\n        \"title\": \"PHP \u0026 MySQL Novice to Ninja\",\n        \"_links\": {\n            \"self\": {\n                \"href\": \"/v1/books/1\"\n            }\n        }\n    }\n}\n\n``` \n\n\nExample - GET collection: GET /v1/books\n```json\n{\n    \"status\": \"success\",\n    \"code\": 200,\n    \"message\": \"OK\",\n    \"data\": [\n        {\n            \"id\": 1,\n            \"title\": \"PHP \u0026 MySQL Novice to Ninja\",\n            \"_links\": {\n                \"self\": {\n                    \"href\": \"/v1/books/1\"\n                }\n            }\n        },\n        {\n            \"id\": 2,\n            \"title\": \"Head First PHP \u0026 MySQL\",\n            \"pages\": 812,\n            \"_links\": {\n                \"self\": {\n                    \"href\": \"/v1/books/2\"\n                }\n            }\n        }\n    ]\n}\n\n``` \nExample - POST resource: POST /v1/books\n\nJSON (any other field will be ignored):\n```json\n{\n    \"data\": {\n        \"title\": \"New Book about PHP\",\n        \"pages\": 123\n    }\n}\n\n``` \nResponse:\n```json\n{\n    \"status\": \"success\",\n    \"code\": 200,\n    \"message\": \"OK\",\n    \"data\": {\n        \"id\": 3,\n        \"title\": \"New Book about PHP\",\n        \"pages\": 123,\n        \"_links\": {\n            \"self\": {\n                \"href\": \"/v1/books/12\"\n            }\n        }\n    }\n}\n```\nExample - PUT resource: PUT /v1/books/1\n\nJSON (any other field will be ignored):\n```json\n{\n    \"data\": {\n        \"title\": \"Edit title\",\n        \"pages\": 1000\n    }\n}\n\n``` \nResponse:\n```json\n{\n    \"status\": \"success\",\n    \"code\": 200,\n    \"message\": \"OK\",\n    \"data\": {\n        \"id\": 1,\n        \"title\": \"Edit title\",\n        \"pages\": 1000,\n        \"_links\": {\n            \"self\": {\n                \"href\": \"/v1/books/1\"\n            }\n        }\n    }\n}\n```\n\nExample - error: Resource not found: GET /v1/books/123123\n```json\n{\n    \"status\": \"error\",\n    \"code\": 404,\n    \"message\": \"Not Found\",\n    \"error\": {\n        \"details\": \"Resource 123123 not found\"\n    }\n}\n```\n\n\nExample - error: Route not found: GET /wrongroute123\n```json\n{\n    \"status\": \"error\",\n    \"code\": 404,\n    \"message\": \"Not Found\",\n    \"error\": {\n        \"details\": \"No route found for \\\"GET /wrongroute123\\\"\"\n    }\n}\n```\n\nExample - 500 Internal Server Error\n```json\n{\n    \"status\": \"error\",\n    \"code\": 500,\n    \"message\": \"Internal Server Error\",\n    \"error\": {\n        \"details\": \"Notice: Undefined variable: view\"\n    }\n}\n```\nExample - form error - POST /v1/books\n```json\n{\n    \"data\": {\n        \"pages\": 123\n    }\n}\n```\nResponse:\n```json\n{\n    \"status\": \"error\",\n    \"code\": 400,\n    \"message\": \"Bad Request\",\n    \"error\": {\n        \"form\": {\n            \"title\": \"This value should not be blank.\"\n        }\n    }\n}\n```\n\n\n\n## Using it as skeleton \u003ca name = \"usage\"\u003e\u003c/a\u003e\n\nUse Fork capability and edit at your own \n\n\n## Contributing \u003ca name = \"contributing\"\u003e\u003c/a\u003e\n\n1. Fork it (\u003chttps://github.com/demartis/symfony5-rest-api/fork\u003e)\n2. Create your feature branch (`git checkout -b feature/fooBar`)\n3. Commit your changes (`git commit -am 'Add some fooBar'`)\n4. Push to the branch (`git push origin feature/fooBar`)\n5. Create a new Pull Request\n\n\n## License \u003ca name = \"license\"\u003e\u003c/a\u003e\n\n[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Fdemartis%2Fsymfony5-rest-api.svg?type=large)](https://app.fossa.io/projects/git%2Bgithub.com%2Fdemartis%2Fsymfony5-rest-api?ref=badge_large)\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdemartis%2Fsymfony5-rest-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdemartis%2Fsymfony5-rest-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdemartis%2Fsymfony5-rest-api/lists"}