A modern, secure blog engine built with Laravel 12, featuring comprehensive input validation, output escaping, professional code standards, design patterns, global helper functions, and unit tests.
- User Authentication & Authorization - Secure login/registration with role-based access
- Profile Management - User profiles with avatars, descriptions, and custom slugs
- Blog Posts - Full CRUD operations with rich content, images, and tags
- Comments System - Threaded comments with moderation and rate limiting
- Tag System - Organize posts with flexible tagging (max 6 tags per post)
- Image Upload - Secure image handling with validation and processing
- Input Sanitization - Global helper functions (
sanitize(),sanitize_required()) for consistent data cleaning - Output Escaping - Laravel's
e()helper for XSS protection in all templates - CSRF Protection - Laravel's built-in CSRF tokens on all forms
- Ownership Middleware - Granular authorization for posts, comments, and profiles
- Rate Limiting - Comment spam protection (10 comments per user per day)
- Image Validation - Strict file type, size, and dimension validation
- PSR-12 Standards - Consistent coding standards throughout
- PHP 8+ Features - Modern PHP with typed properties and return types
- Repository Pattern - Clean separation of concerns
- DRY Principles - Global helper functions eliminate code duplication
- Professional Documentation - Detailed docblocks and comments
- Improved Error Handling - ValidationException for better user experience
- Interfaces - Define contracts for data operations
- Repositories - Implement business logic and data access
- Controllers - Handle HTTP requests and delegate to repositories
- Middleware - Handle cross-cutting concerns like authorization
app/
├── Http/
│ ├── Controllers/ # Thin controllers delegating to repositories
│ └── Middleware/ # Authorization and security middleware
├── Repositories/ # Business logic implementation
├── Interfaces/ # Repository contracts
├── Models/ # Eloquent models
├── Services/ # Business services (Authorization, Image, Slug)
├── Classes/ # Utility classes (Imgstore, Tagpost, etc.)
└── helpers.php # Global helper functions (sanitize, sanitize_required)
tests/
├── Unit/ # Comprehensive unit tests
└── Feature/ # Integration tests
- PHP 8.1+
- Composer
- Node.js & NPM
- SQLite (for testing) or MySQL/PostgreSQL
-
Clone the repository
git clone https://github.com/boldib/easyblog cd easyblog -
Install PHP dependencies
composer install
-
Install Node dependencies
npm install
-
Environment setup
cp .env.example .env php artisan key:generate
-
Database setup
php artisan migrate php artisan db:seed
-
Build assets
npm run build
-
Create storage symlink
php artisan storage:link
-
Start the development server
php artisan serve
# Run all tests
php artisan test
# Run unit tests only
php artisan test --testsuite=Unit
# Run with coverage
php artisan test --coverage
# Run specific test file
php artisan test tests/Unit/AuthorizationServiceTest.php- Test Isolation: Direct implementation pattern to resolve autoloader conflicts
- Comprehensive Mocking: Full dependency injection mocking with Mockery
- Performance Testing: Slug generation performance tests with 50+ conflicts
- Edge Case Coverage: Unicode, empty strings, large values, boundary conditions
- Security Testing: Authorization, forbidden slugs, input validation
- Database Testing: SQLite in-memory for fast, isolated tests
- Factory Usage: Model factories for consistent, reliable test data
# Check code standards
./vendor/bin/pint --test
# Fix code standards
./vendor/bin/pint- No strict types declarations (as per project requirements)
- Professional docblocks on all methods
- Type hints for parameters and return types
- Consistent naming following Laravel conventions
pint.json- PSR-12 code style configurationphpunit.xml- Test suite configuration.env- Environment variablesconfig/- Laravel configuration files
- Follow PSR-12 coding standards
- Write tests for new features
- Ensure all security measures are maintained
- Add proper documentation and comments
- Run tests before submitting PRs
This project is open-source software licensed under the MIT license.
- Laravel 12 - PHP web framework
- PHP 8.3 - Server-side scripting with modern features
- Tailwind CSS - Utility-first CSS framework
- Vite - Frontend build tool
- PHPUnit - Testing framework with 100% success rate
- Mockery - Advanced mocking framework for test isolation
- SQLite - In-memory database for lightning-fast tests
- Laravel Pint - PSR-12 code style fixer
EasyBlog - A secure, modern blog engine demonstrating Laravel best practices, design patterns,comprehensive security measures, professional code standards, and unit tests.