A Laravel-based application that allows users to subscribe to websites and receive email notifications for new posts.
- Subscribe to websites using an email address.
- Create posts for subscribed websites.
- Send email notifications to subscribers for new posts.
- Ensure no duplicate notifications are sent.
- Use queues to handle email sending in the background.
- PHP 7.4 or higher
- Composer
- MySQL
- Mailtrap or other email testing tool (for development)
git clone [email protected]:roc41d/notify-me.git
cd notify-me
composer install
cp .env.example .env
Edit the .env file to set up your database, mail, and queue configurations:
APP_NAME=Laravel
APP_ENV=local
APP_KEY=base64:YOUR_APP_KEY_HERE
APP_DEBUG=true
APP_URL=http://localhost
LOG_CHANNEL=stack
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=your_database
DB_USERNAME=your_username
DB_PASSWORD=your_password
BROADCAST_DRIVER=log
CACHE_DRIVER=file
QUEUE_CONNECTION=database
SESSION_DRIVER=file
SESSION_LIFETIME=120
REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379
MAIL_MAILER=smtp
MAIL_HOST=smtp.mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=your_mailtrap_username
MAIL_PASSWORD=your_mailtrap_password
MAIL_ENCRYPTION=null
[email protected]
MAIL_FROM_NAME="${APP_NAME}"
php artisan key:generate
php artisan migrate
php artisan db:seed
Start the queue worker to process the email jobs.
php artisan queue:work
Start the scheduler worker to process cron jobs.
php artisan schedule:work
php artisan serve
http://localhost:8000/api/
You can now use Postman or any other API client to interact with the endpoints.
Endpoint: POST /websites
Request Body:
{
"name": "Acme Inc",
"url": "https://acmeinc.xzy"
}
Endpoint: Get /websites?limit=20
Endpoint: POST /subscribe
Request Body:
{
"email": "[email protected]",
"website_id": 1
}
Endpoint: POST /posts
Request Body:
{
"website_id": 1,
"title": "New Post Title",
"description": "Description of the new post."
}
Endpoint: GET /posts?limit=20
Note: For testing purposes, the command checks for new posts and notifies subscribers every five minutes.
This can be change in /routes/console.php
Schedule::command(SendEmails::class)->everyFiveMinutes();