A blog management system built with PHP MVC architecture, featuring an admin panel for managing posts, categories, users, and authentication flows.
Dashboard |
Posts Management |
Users Management |
User Editing |
Homepage |
Post Detail |
- Session-based authentication (login/logout)
- User registration with email verification
- Role-based access control (Admin, Editor, Author)
- Posts: Full CRUD operations with search, filter, and pagination
- Categories: Manage blog categories with post count tracking
- Users: User management with role and status control
- Form validation for all inputs
- Image upload support for user avatars and post thumbnails
- PDO prepared statements (SQL injection prevention)
- XSS and CSRF protection
- Bcrypt password hashing
- Secure file upload validation
- Centralized application logging via
Core\\Logger - Controller actions are wrapped with centralized try/catch handling
- Runtime errors are written to
storage/logs/app.log - Mail, database, and unhandled request errors are logged in one place
Backend: PHP, MySQL, PDO, Composer (Dotenv, PHPMailer)
Frontend: AdminLTE 4, Bootstrap, Font Awesome
git clone https://github.com/huydev14/blog-management-php.git
cd blogcomposer installCopy the example environment file and edit it:
# Copy .env.example to .env
cp .env.example .envUpdate the following settings in .env:
# Database Configuration
DB_HOST=localhost
DB_PORT=3306
DB_NAME=blog
DB_USER=root
DB_PASS=
# Application URL
BASE_URL=http://localhost/blog
APP_BASE_PATH=/blog
# Mail Configuration (for email features)
MAIL_HOST=smtp.gmail.com
MAIL_USER=your-email@gmail.com
MAIL_PASS=your-app-passwordGmail Setup (Optional):
If you want to enable email features:
- Enable 2-factor authentication on your Gmail account
- Generate an App Password: https://myaccount.google.com/apppasswords
- Use the generated 16-character password in
MAIL_PASS
Create and import database:
- Create database named
blog - Import SQL dump file
database/blog.sql
Make sure the logs directory is writable by your web server:
mkdir -p storage/logs
chmod -R 775 storage- Make sure Apache is running in XAMPP/WAMP
- Open your browser and navigate to:
http://localhost/blog/ - Login with the default admin account:
The system comes with pre-configured test accounts:
| Role | Password | Description | |
|---|---|---|---|
| Admin | admin@devblog.com | 123456 | Full system access |
| Editor | editor@devblog.com | 123456 | Content management |
| Author | minhdev@gmail.com | 123456 | Post creation |
- Main log file:
storage/logs/app.log - Typical logged events:
- Controller runtime exceptions
- Database connection errors
- Mail send/configuration errors
- Unhandled request exceptions
Quick check:
tail -f storage/logs/app.logblog/
├── database/ # SQL file testing dump
├── public/ # index.php, assets, .htaccess
├── routes/ # Route definition
├── src/
│ ├── app/
│ │ ├── Controllers/ # Admin & Client controllers
│ │ ├── Models/ # Database entities
│ │ ├── Views/ # Templates (layouts, emails)
│ │ ├── Middlewares/ # Authentication guard
│ │ └── Services/ # Mail Service, File Upload Service
│ ├── Core/ # Core files (Router, Controller, Model, View, Database, Logger)
│ ├── configs/ # Configuration file
│ └── helpers/ # Helper functions
├── storage/
│ └── logs/ # Centralized log files
├── vendor/ # Composer dependencies
├── .env # Environment config
Enable detailed error messages in .env:
APP_DEBUG=trueDisable in production:
APP_DEBUG=falseTran Gia Huy
- GitHub: @huydev14
- Email: huydev14@gmail.com





