- PHP 8.4 or higher
- Composer
- MySQL/PostgreSQL database
- Node.js and npm (for frontend assets)
composer install
npm installCopy .env.example to .env and configure your database:
cp .env.example .envUpdate the following in your .env:
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=your_database_name
DB_USERNAME=your_username
DB_PASSWORD=your_password
php artisan key:generatephp artisan migrateThis will create the messages table along with all other required tables.
npm run buildFor development:
npm run devphp artisan serveThe application will be available at http://localhost:8000
- Login to your account at
/login - Navigate to Messages at
/messages - Start a new conversation by clicking "New Message"
- Select a user from the dropdown
- Type your message and click "Send"
All API endpoints require authentication via Laravel Sanctum.
curl -X POST http://localhost:8000/api/messages \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-d '{
"recipient_id": 2,
"body": "Hello, this is my message"
}'curl http://localhost:8000/api/messages \
-H "Accept: application/json"curl http://localhost:8000/api/messages/2 \
-H "Accept: application/json"Run the test suite:
# Run all tests
php artisan test
# Run only messaging tests
php artisan test --filter=Message- Message Encryption: All message bodies are encrypted in the database using Laravel's encryption
- Authorization: Users can only access their own messages
- Authentication: All routes require authentication
- CSRF Protection: All forms include CSRF tokens
- Input Validation: All inputs are validated and sanitized
Solution: Run composer dump-autoload
Solution:
- Check your
.envdatabase configuration - Ensure the database exists
- Verify database credentials
Solution: Run php artisan key:generate
Solution:
- Check that migrations ran successfully
- Verify authentication is working
- Check browser console for JavaScript errors
To work on the messaging system:
- Models:
app/Models/Message.php - Controllers:
app/Http/Controllers/MessageController.php - Views:
resources/views/messages/ - Routes:
- API:
routes/api.php - Web:
routes/web.php
- API:
- Tests:
tests/Feature/Message*.php
See MESSAGING.md for detailed API documentation and usage examples.