{"id":17973177,"url":"https://github.com/sarrafi-mo/simple-php-api","last_synced_at":"2025-04-03T23:13:56.332Z","repository":{"id":259218150,"uuid":"876555753","full_name":"sarrafi-mo/simple-php-api","owner":"sarrafi-mo","description":"Lightweight PHP API for handling CRUD operations.","archived":false,"fork":false,"pushed_at":"2024-10-24T14:27:44.000Z","size":70,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-09T10:47:21.000Z","etag":null,"topics":["api","backend","crud","php","php-api"],"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/sarrafi-mo.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":"2024-10-22T07:06:38.000Z","updated_at":"2024-10-24T14:27:56.000Z","dependencies_parsed_at":"2024-10-25T18:17:34.535Z","dependency_job_id":"37db076b-7314-4f18-b5dd-a1a45cb4862d","html_url":"https://github.com/sarrafi-mo/simple-php-api","commit_stats":null,"previous_names":["sarrafi-mo/simple-api-php","sarrafi-mo/simple-php-api"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sarrafi-mo%2Fsimple-php-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sarrafi-mo%2Fsimple-php-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sarrafi-mo%2Fsimple-php-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sarrafi-mo%2Fsimple-php-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sarrafi-mo","download_url":"https://codeload.github.com/sarrafi-mo/simple-php-api/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247092393,"owners_count":20882218,"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","backend","crud","php","php-api"],"created_at":"2024-10-29T16:27:50.377Z","updated_at":"2025-04-03T23:13:56.313Z","avatar_url":"https://github.com/sarrafi-mo.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n# Simple PHP API\n\nA lightweight PHP API for handling CRUD (Create, Read, Update, Delete) operations for user management. This project demonstrates how to build a basic RESTful API using PHP and MySQL.\n\n## Features\n- **GET**: Fetch all users from the database.\n- **POST**: Add a new user with a name and email.\n- **PUT**: Update the details of an existing user.\n- **DELETE**: Remove a user from the database.\n\n## Technologies Used\n- PHP\n- MySQL\n- JavaScript (with Axios)\n- HTML \u0026 Bootstrap (for client-side testing)\n\n![postman.html page](images/postman.png)\n\n\n## Setup Instructions\n1. Clone the repository:\n    ```\n    git clone https://github.com/sarrafi-mo/simple-api-php.git\n    ```\n2. Navigate to the project directory:\n    ```\n    cd simple-api-php\n    ```\n3. Import the `users.sql` file into your MySQL database to create the `users` table.\n4. Update the database connection settings in `db.php` if necessary.\n5. Run the PHP server:\n    ```\n    php -S localhost:8000\n    ```\n6. Access the API via `http://localhost:8000/api.php`.\n\n## Endpoints\n- **GET /api.php**: Retrieve all users.\n- **POST /api.php**: Add a new user. Requires JSON body with `name` and `email`.\n- **PUT /api.php**: Update an existing user. Requires JSON body with `id`, `name`, and `email`.\n- **DELETE /api.php**: Delete a user. Requires JSON body with `id`.\n\n### Example JSON Payloads\n- **POST**:\n    ```json\n    {\n        \"name\": \"John Doe\",\n        \"email\": \"john@example.com\"\n    }\n    ```\n- **PUT**:\n    ```json\n    {\n        \"id\": 1,\n        \"name\": \"John Smith\",\n        \"email\": \"john.smith@example.com\"\n    }\n    ```\n- **DELETE**:\n    ```json\n    {\n        \"id\": 1\n    }\n    ```\n\n## Testing the API\nThe `postman.html` file in the project can be used for basic testing of the API. It provides a simple interface built with Bootstrap and Axios.\n\n1. Open `postman.html` in your browser.\n2. Use the forms to interact with the API.\n\n## License\nThis project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsarrafi-mo%2Fsimple-php-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsarrafi-mo%2Fsimple-php-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsarrafi-mo%2Fsimple-php-api/lists"}