{"id":17437154,"url":"https://github.com/brp-labs/rest-api","last_synced_at":"2026-04-27T12:39:47.276Z","repository":{"id":257920011,"uuid":"861759574","full_name":"brp-labs/rest-api","owner":"brp-labs","description":"REST API (CRUD) - with the ability to perform string searches as well","archived":false,"fork":false,"pushed_at":"2024-09-30T21:26:42.000Z","size":52,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-06-01T09:52:42.147Z","etag":null,"topics":["mysql","php","sql"],"latest_commit_sha":null,"homepage":"","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/brp-labs.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","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":"2024-09-23T13:20:16.000Z","updated_at":"2024-10-16T23:25:03.000Z","dependencies_parsed_at":"2024-10-17T01:31:09.183Z","dependency_job_id":null,"html_url":"https://github.com/brp-labs/rest-api","commit_stats":null,"previous_names":["brp-labs/rest-api"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/brp-labs/rest-api","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brp-labs%2Frest-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brp-labs%2Frest-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brp-labs%2Frest-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brp-labs%2Frest-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/brp-labs","download_url":"https://codeload.github.com/brp-labs/rest-api/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brp-labs%2Frest-api/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32337274,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-26T23:26:28.701Z","status":"online","status_checked_at":"2026-04-27T02:00:06.769Z","response_time":128,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["mysql","php","sql"],"created_at":"2024-10-17T11:06:13.166Z","updated_at":"2026-04-27T12:39:47.258Z","avatar_url":"https://github.com/brp-labs.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003ch3\u003eREST API (CRUD) - with the ability to perform string searches as well\u003c/h3\u003e\n\u003cb\u003eDesign Pattern:\u003c/b\u003e MVC (Model, View, Controller)\u003cbr/\u003e\n\u003cb\u003eAuthor:\u003c/b\u003e Brian Ravn Pedersen, Data Engineer and Software Developer\u003cbr/\u003e\n\u003cb\u003eCreated:\u003c/b\u003e 2024-09-18\u003cbr/\u003e\n\u003cb\u003eFiles:\u003c/b\u003e index.php, schema.sql, Controller.php, Database.php, Model.php, README.md, LICENSE.txt\u003cbr/\u003e\n\u003cb\u003eLanguages used:\u003c/b\u003e PHP, SQL\u003cbr/\u003e\n\u003cb\u003eGitHub Repository:\u003c/b\u003e https://github.com/brp-labs/rest-api\u003cbr/\u003e\n\u003cbr/\u003e\nThe REST API has been tested with \u003cb\u003ePostman API Platform\u003c/b\u003e (desktop) against a MySQL database (MariaDB) running on a local server (Apache/XAMPP).\n\n\u003chr/\u003e\n\n\u003ch3\u003eHow to use the REST API with e.g., Postman API Platform\u003c/h3\u003e\n\n\u003cb\u003eCREATE:\u003c/b\u003e Use the HTTP method POST to create a new post in the database.\u003cbr/\u003e\n    Submit the body in JSON format with at least the required keys (see below):\u003cbr/\u003e\n      \u003ci\u003ee.g.,\u003c/i\u003e \u003ccode\u003e{ \"username\": \"John Doe\", \"email\": \"john\u0026#64;\u003c!-- --\u003edoe\u0026#46;com\", \"entity\": \"Business Intelligence\" }\u003c/code\u003e\u003cbr/\u003e\n\u003cbr/\u003e\n\u003cb\u003eREAD:\u003c/b\u003e Use the HTTP method GET to read or search for a post in the database. The response is returned in JSON format.\u003cbr/\u003e\n    \u003cb\u003eRead a single\u003c/b\u003e post (use the \u003ccode\u003eid\u003c/code\u003e key):\u003cbr/\u003e\n    \u003ci\u003ee.g.,\u003c/i\u003e \u003ccode\u003e../index.php?id=23\u003c/code\u003e\u003cbr/\u003e\n    \u003cb\u003eRead all\u003c/b\u003e posts:\u003cbr/\u003e\n      \u003ci\u003ee.g.,\u003c/i\u003e \u003ccode\u003e../index.php\u003c/code\u003e\u003cbr/\u003e\n    \u003cb\u003eSearch\u003c/b\u003e for posts using the \u003ccode\u003eq\u003c/code\u003e key and a specified query string:\u003cbr/\u003e\n      \u003ci\u003ee.g.,\u003c/i\u003e \u003ccode\u003e../index.php?q=john\u003c/code\u003e\u003cbr/\u003e\n      The queried table fields are: username, email. The contains method is being used in SQL, ie., LIKE '%\u003cquerystring\\\u003e%'\u003cbr/\u003e\n\u003cbr/\u003e\n\u003cb\u003eUPDATE:\u003c/b\u003e Use the HTTP method PUT to update a post in the database.\u003cbr/\u003e\n    Submit the body in JSON format with the keys that need to be changed. Required keys must not be empty (see below). Use the mandatory \u003ccode\u003eid\u003c/code\u003e key in the body to identify the post to update.\u003cbr/\u003e\n      \u003ci\u003ee.g.,\u003c/i\u003e \u003ccode\u003e{ \"id\": 23, \"entity\": \"Development Division\" }\u003c/code\u003e\u003cbr/\u003e\n\u003cbr/\u003e\n\u003cb\u003eDELETE:\u003c/b\u003e Use the HTTP method DELETE to delete a post in the database. Use the mandatory \u003ccode\u003eid\u003c/code\u003e key to identify the post to delete.\u003cbr/\u003e\n    Delete post (with \u003ccode\u003eid\u003c/code\u003e=23):\u003cbr/\u003e\n      \u003ci\u003ee.g.,\u003c/i\u003e \u003ccode\u003e../index.php?id=23\u003c/code\u003e\n\n\u003ch3\u003eKeys, Required Keys, Unique Keys, Queried Keys\u003c/h3\u003e\nThe keys, required keys, and unique keys, all declared in the \u003cb\u003eController Class\u003c/b\u003e, are specified in order to uphold functional logic in the database.\u003cbr/\u003e \n\n\u003cbr/\u003e\n\u003cb\u003eKeys:\u003c/b\u003e The keys refer to the columns in the table \u003ccode\u003eusers\u003c/code\u003e (cf. the file: \u003ccode\u003eschema.sql\u003c/code\u003e). The keys are: \u003ccode\u003eid\u003c/code\u003e, \u003ccode\u003euser_id\u003c/code\u003e, \u003ccode\u003eusername\u003c/code\u003e, \u003ccode\u003eemail\u003c/code\u003e, \u003ccode\u003eentity\u003c/code\u003e, \u003ccode\u003eentitycode\u003c/code\u003e. The \u003ccode\u003eid\u003c/code\u003e, however, is the primary key and is used for auto-incrementing by the database.\u003cbr/\u003e\n\n\u003cbr/\u003e\n\u003cb\u003eRequired Keys:\u003c/b\u003e The required keys are those that must be declared when creating a new post in the \u003ccode\u003eusers\u003c/code\u003e table. The required keys cannot be empty (\u003ci\u003ei.e.,\u003c/i\u003e NULL). Some content for these keys is mandatory. The required keys are: \u003ccode\u003eusername\u003c/code\u003e, \u003ccode\u003eemail\u003c/code\u003e.\u003cbr/\u003e\n\n\u003cbr/\u003e\n\u003cb\u003eUnique Keys:\u003c/b\u003e The unique keys do not need to be declared when a new post is created. Their default value on table creation is NULL. However, if a unique key is used, the key must have its own content (value). Two different posts are not allowed to have the same unique key with identical content (value). In that sense, a unique key must have unique content (value). However, multiple posts can have the same unique key's content set to NULL without violating the uniqueness rule. The unique keys are:  \u003ccode\u003euser_id\u003c/code\u003e, \u003ccode\u003eusername\u003c/code\u003e, \u003ccode\u003eemail\u003c/code\u003e.\u003cbr/\u003e\n\n\u003cbr/\u003e \n\u003cb\u003eQueried Keys:\u003c/b\u003e When using the search functionality, the queried keys are \u003ccode\u003eusername\u003c/code\u003e and \u003ccode\u003eemail\u003c/code\u003e. The keys used for quering can be changed with some minor modifications to the SQL code in the \u003cb\u003eModel Class\u003c/b\u003e file. If needed, go to the search function in the Model Class file and alter the \u003ccode\u003e$sql\u003c/code\u003e variable as well as the value bindings.\n\n\u003cbr/\u003e\n\u003ch3\u003eDatabase Configuration\u003c/h3\u003e\nThe database configuration is shown in the \u003cb\u003eDatabase Class\u003c/b\u003e file. The file \u003ccode\u003eschema.sql\u003c/code\u003e contains the sequence of SQL batches used to create the database and the table, including its columns and specifications.\n\n\u003cbr/\u003e\n\u003ch3\u003eMetadata\u003c/h3\u003e\nWhenever a dataset is returned from the database as a result of reading a single post, reading all posts, or searching for one or more posts, a separate array is inserted right before the dataset array. This separate array at the very top, called \u003ccode\u003eInfo\u003c/code\u003e, gives a timestamp and the number of posts returned from the database. The timezone used is set at the top of the \u003cb\u003eController Class\u003c/b\u003e and is default set to 'Europe/Copenhagen'. And, of course, the timezone should be adjusted if the application runs in a different timezone. The array containing the dataset, by the way, is called \u003ccode\u003eData\u003c/code\u003e. \n\n\n\u003cbr/\u003e\n\u003ch3\u003eLicense\u003c/h3\u003e\nAnyone who would like to use this REST API can do so and, of course, modify the code, the database configuration, and the list of different keys as well, in order to adapt it to one's actual needs - in compliance with the content of the attached LICENSE file.\n\n\u003cbr/\u003e\n\u003chr/\u003e\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbrp-labs%2Frest-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbrp-labs%2Frest-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbrp-labs%2Frest-api/lists"}