Welcome to the PHP CRUD API Generator repository! This tool helps you quickly create a fully functional API for your MariaDB or MySQL database using PHP. Whether you are a developer looking to streamline your API development or a beginner eager to learn, this project provides a simple and effective solution.
- Easy Setup: Quickly generate APIs with minimal configuration.
- Supports MariaDB and MySQL: Work with the databases you know.
- RESTful API: Follow REST principles for easy integration.
- Customizable: Modify generated code to suit your needs.
- Lightweight: Designed to be efficient and fast.
To get started, download the latest release from the Releases section. After downloading, extract the files to your server directory.
- PHP 7.2 or higher
- MariaDB or MySQL
- Composer (for dependency management)
-
Clone the Repository:
git clone https://github.com/tomo3076/PHP-CRUD-API-Generator.git
-
Navigate to the Directory:
cd PHP-CRUD-API-Generator
-
Install Dependencies:
composer install
-
Configure Your Database: Open the
config.php
file and set your database credentials. -
Run the Application: Access the API through your web server.
Once you have installed the API generator, you can start creating your endpoints. Hereβs how to use the tool effectively:
- Define Your Database Structure: Create tables in your MariaDB or MySQL database.
- Generate the API: Use the command line to generate your API endpoints.
php generate.php
- Test Your API: Use tools like Postman or curl to test the endpoints.
The API supports various endpoints for CRUD operations:
- Create: POST request to create a new record.
- Read: GET request to retrieve records.
- Update: PUT request to update an existing record.
- Delete: DELETE request to remove a record.
-
Create a Record:
curl -X POST -H "Content-Type: application/json" -d '{"name": "John Doe"}' http://yourapi.com/api/users
-
Read Records:
curl -X GET http://yourapi.com/api/users
-
Update a Record:
curl -X PUT -H "Content-Type: application/json" -d '{"name": "Jane Doe"}' http://yourapi.com/api/users/1
-
Delete a Record:
curl -X DELETE http://yourapi.com/api/users/1
To configure your API, modify the config.php
file. You will need to set the following parameters:
- Database Host: Your database server address.
- Database Name: The name of your database.
- Database User: Your database username.
- Database Password: Your database password.
define('DB_HOST', 'localhost');
define('DB_NAME', 'your_database');
define('DB_USER', 'your_username');
define('DB_PASS', 'your_password');
We welcome contributions! If you would like to help improve the PHP CRUD API Generator, please follow these steps:
- Fork the repository.
- Create a new branch (
git checkout -b feature/YourFeature
). - Make your changes.
- Commit your changes (
git commit -m 'Add some feature'
). - Push to the branch (
git push origin feature/YourFeature
). - Open a Pull Request.
This project is licensed under the MIT License. See the LICENSE file for details.
If you have any questions or need support, please check the Releases section for updates. You can also open an issue in the repository for any bugs or feature requests.
Thank you for using the PHP CRUD API Generator! We hope this tool makes your API development process easier and more efficient. Happy coding!