A simple and lightweight API for managing newsletter subscriptions, built with Slim Framework and PHP.
- Easy integration with any frontend
- RESTful endpoints for subscribing and unsubscribing
- Minimal dependencies and fast setup
- Clone the repository:
git clone https://github.com/crossben/slim-php-newsletter.git cd slim-php-newsletter - Install dependencies with Composer:
composer install
- Configure your environment:
Copy.env.exampleto.envand update settings as needed. - Start the API server:
php -S localhost:8080 -t public
- Endpoint:
POST http://localhost:8080/subscribe/{email} - Request Body:
{ "email": "example@example.com" } - Success Response:
{ "message": "Subscribed successfully!" }
- Endpoint:
DELETE http://localhost:8080/unsubscribe/{email} - Example:
http://localhost:8080/unsubscribe/example@example.com - Success Response:
{ "message": "Unsubscribed successfully!" } - Error Responses:
{ "error": "Email not found" }{ "error": "Invalid email" }
MIT License