https://github.com/1dev-hridoy/slimapitemplate
A robust and feature-rich API template built with PHP Slim Framework, providing ready-to-use implementations for weather data, QR code generation, and more.
https://github.com/1dev-hridoy/slimapitemplate
php-api php-slim-framework php7 slim-framework
Last synced: about 1 year ago
JSON representation
A robust and feature-rich API template built with PHP Slim Framework, providing ready-to-use implementations for weather data, QR code generation, and more.
- Host: GitHub
- URL: https://github.com/1dev-hridoy/slimapitemplate
- Owner: 1dev-hridoy
- Created: 2025-03-29T17:01:34.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2025-03-29T17:47:22.000Z (about 1 year ago)
- Last Synced: 2025-03-29T18:20:13.500Z (about 1 year ago)
- Topics: php-api, php-slim-framework, php7, slim-framework
- Language: PHP
- Homepage:
- Size: 33.2 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Slim API Template
A robust and feature-rich API template built with PHP Slim Framework, providing ready-to-use implementations for weather data, QR code generation, and more.
## Features
- 🚀 Built with Slim 4 Framework
- 🌤️ Weather API Integration with OpenWeatherMap
- 📱 QR Code Generation API
- 🔐 Proper Error Handling
- 📁 Well-organized Project Structure
- 🛠️ Easy to Extend and Customize
## Project Structure
```plaintext
api-project/
├── composer.json
├── .htaccess
├── public/
│ ├── index.php
│ └── .htaccess
├── src/
│ ├── Config/
│ │ └── settings.php
│ ├── Controllers/
│ │ ├── HelloController.php
│ │ ├── WeatherController.php
│ │ └── QRCodeController.php
│ ├── Routes/
│ │ └── api.php
│ └── bootstrap.php
└── vendor/
```
## Requirements
- PHP >= 7.4
- Composer
- Apache/Nginx Web Server
- GD extension (for QR code generation)
## Installation
1. Clone the repository:
```bash
git clone https://github.com/1dev-hridoy/SlimApiTemplate.git
```
2. Install dependencies:
```bash
composer install
```
3. Configure your web server to point to the `public` directory
4. Copy `.htaccess` files to their respective locations
## Available APIs
### 1. Hello World Endpoint
```http
GET /api/hello
```
### 2. Weather API Endpoints
```http
# Get current weather
GET /api/weather?city={cityName}
# Get weather forecast
GET /api/weather/forecast?city={cityName}
```
Parameters:
- `city`: Name of the city (required)
### 3. QR Code Generation Endpoints
```http
# Generate QR code as image
GET /api/qr/generate?text={text}&size={size}&label={label}
# Generate QR code as base64
GET /api/qr/base64?text={text}
```
Parameters:
- `text`: Content to encode in QR code (required)
- `size`: Size of QR code in pixels (optional, default: 300)
- `label`: Text label below QR code (optional)
## Example Usage
### Weather API
```javascript
fetch('http://your-domain/api/weather?city=London')
.then(response => response.json())
.then(data => console.log(data));
```
### QR Code Generation
```html

```
## Configuration
### Weather API
Update the OpenWeather API key in `src/Controllers/WeatherController.php`:
```php
private $apiKey = 'your-api-key';
```
## Contributing
1. Fork the repository
2. Create a new branch (`git checkout -b feature/improvement`)
3. Commit your changes (`git commit -am 'Add new feature'`)
4. Push to the branch (`git push origin feature/improvement`)
5. Create a Pull Request
## Author
- **Hridoy** - [GitHub Profile](https://github.com/1dev-hridoy)
## License
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details
## Support
If you find this template helpful, please consider giving it a ⭐️ on GitHub!
## Last Updated
2025-03-29 17:26:17 UTC by @hridoy09bg