A modern Laravel 12 application for managing posts and comments with comprehensive features including authentication, email notifications, and RESTful API endpoints.
- Posts & Comments: Complete CRUD operations with role-based authorization via Laravel Policies
- Blade Views: Dynamic and responsive frontend templates with modern UI
- RESTful API: Fully functional API endpoints for posts and comments management
- Email Notifications: SMTP email notifications when comments are added to posts
- Service Classes: Clean architecture with business logic separated into dedicated service classes
- Authorization Policies: Role-based access control for posts and comments operations
- API Resources & Helpers: Structured API response formatting with consistent success/error handling
- Unit Testing: Comprehensive tests for controllers and services to ensure functionality
- Validation & Error Handling: Robust validation rules and structured exception logging
- Database Seeding: Pre-populated data for testing and development
Before installing this application, ensure you have the following installed on your system:
- PHP 8.2+ with required extensions (PDO, Mbstring, Tokenizer, XML, Ctype, JSON)
- Composer (Dependency Manager for PHP)
- Node.js 16+ & npm (for frontend asset compilation)
- Git (Version control)
- Database: SQLite (default) or MySQL/MariaDB
- Web Server: Apache or Nginx (optional for production)
git clone https://github.com/elkhokh/TaskFR.git
cd TaskFRInstall PHP dependencies via Composer:
composer installInstall frontend dependencies:
npm install
npm run buildCopy the environment variables file:
cp .env.example .envGenerate application key:
php artisan key:generateFor SQLite (default):
touch database/database.sqliteOr update .env for MySQL:
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=taskfr
DB_USERNAME=your_username
DB_PASSWORD=your_passwordConfigure SMTP settings in your .env file:
MAIL_MAILER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=465
MAIL_USERNAME=your-email@gmail.com
MAIL_PASSWORD=your-app-password
MAIL_ENCRYPTION=ssl
MAIL_FROM_ADDRESS=your-email@gmail.com
MAIL_FROM_NAME="${APP_NAME}"Note: For Gmail, you'll need to use an App Password instead of your regular password. Follow Google's guide to generate one.
Run migrations and seed the database:
php artisan migrate --seedCreate symbolic link for storage:
php artisan storage:linkStart the Laravel development server:
php artisan serveThe application will be available at http://localhost:8000
For email notifications, configure queue settings:
QUEUE_CONNECTION=databaseThen run:
php artisan queue:table
php artisan migrate
php artisan queue:workFor better performance in production:
php artisan config:cache
php artisan route:cache
php artisan view:cacheComplete API documentation is available via Postman:
GET /api/posts- List all postsPOST /api/posts- Create a new postGET /api/posts/{id}- Get specific postPUT /api/posts/{id}- Update a postDELETE /api/posts/{id}- Delete a postGET /api/posts/{id}/comments- Get post commentsPOST /api/posts/{id}/comments- Add comment to post
Run the test suite:
# Run all tests
php artisan test
# Run specific test file
php artisan test tests/Feature/PostControllerTest.php
# Run with coverage (if configured)
php artisan test --coverageTaskFR/
βββ app/
β βββ Http/
β β βββ Controllers/
β β βββ Requests/
β β βββ Resources/
β βββ Models/
β βββ Policies/
β βββ Services/
β βββ Mail/
βββ resources/
β βββ views/
β βββ js/
βββ routes/
β βββ web.php
β βββ api.php
βββ database/
β βββ migrations/
β βββ seeders/
βββ tests/
βββ Feature/
βββ Unit/
The application uses Laravel's built-in authentication system with additional policies for:
- Post Management: Only authors can edit/delete their posts
- Comment Management: Users can delete their own comments
- Admin Access: Admin users have full access to all resources
- Set environment to production:
APP_ENV=production
APP_DEBUG=false- Optimize for production:
composer install --optimize-autoloader --no-dev
php artisan config:cache
php artisan route:cache
php artisan view:cache- Configure web server (Nginx/Apache) to point to
public/directory
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
Permission Errors:
sudo chown -R www-data:www-data storage bootstrap/cache
sudo chmod -R 775 storage bootstrap/cacheCache Issues:
php artisan cache:clear
php artisan config:clear
php artisan view:clearEmail Not Sending:
- Verify SMTP credentials
- Check firewall settings
- Ensure queue worker is running if using queues
=======
Your image is now properly referenced at:
BolgTask/
βββ public/
β βββ images/
β βββ image.png β Your email screenshot
βββ README.md
This project is licensed under the MIT License. See the LICENSE file for details.
elkhokh
- GitHub: @elkhokh
- Laravel Framework Team
- Contributors and testers
- Open source community
For more information, please visit the Laravel Documentation or open an issue on GitHub.