A modern, framework-free PHP news portal built with clean architecture, custom routing, and real-world functionality. Perfect for learning modern PHP development patterns or deploying as a lightweight news management system.
Simply News App is a full-featured news management system built entirely in PHP without relying on any framework. This project demonstrates professional PHP development practices including MVC architecture, custom routing, exception handling, and database abstraction.
Whether you're a student learning PHP, a developer exploring framework-free architecture, or someone needing a lightweight news portalβthis application is designed to be simple, readable, and extensible.
- π° Multi-Category News - Organize articles by topics and categories
- π€ User Authentication - Secure login/signup with session management
- π Role-Based Access Control - Separate permissions for admins and regular users
- βοΈ Content Management - Create, edit, and publish news articles
- π¬ Comment System - Readers can engage with articles via comments
- π¨ Responsive UI - Modern, mobile-friendly design with vanilla CSS & JavaScript
- π£οΈ Custom Router - Lightweight HTTP routing engine without framework overhead
- ποΈ Database Abstraction - Clean model layer with PDO for database operations
- π Docker Ready - Easily deployable with Docker containers
- π§ Configuration Management - Environment-based settings via
.envfile
Simply News App/
βββ π src/ # Core application logic
β βββ Controllers/ # Request handlers
β βββ Models/ # Database layer
β βββ Classes/ # Utility classes
β βββ Exception/ # Custom exceptions
β βββ Router.php # Custom routing engine
β βββ Request.php # HTTP request wrapper
β βββ Response.php # HTTP response wrapper
β βββ View.php # Template renderer
βββ π config/ # Application configuration
β βββ routes.php # Route definitions
β βββ configuration.php # App settings
β βββ database.php # DB configuration
β βββ env.php # Environment variables
βββ π database/ # Database initialization
β βββ init.php # Database setup script
β βββ schema.sql # Schema reference
βββ π templates/ # View files (MVC templates)
β βββ pages/ # Page-specific templates
βββ π public/ # Frontend assets
β βββ css/ # Stylesheets
β βββ js/ # Client-side scripts
β βββ img/ # Images
β βββ icon/ # Icons & favicons
βββ π docker-entrypoint.sh # Docker startup script
βββ π Dockerfile # Docker image definition
βββ π docker-compose.yml # Multi-container setup
βββ π index.php # Application entry point
βββ π .env # Environment variables
- PHP 8.1 or higher
- MySQL 8.0 or higher
- Docker & Docker Compose (for Docker deployment)
- Git
-
Clone the repository:
git clone https://github.com/LukaszKwiatkowski94/Simply-news-app.git cd Simply-news-app -
Configure
.env:cp example.env .env
Edit
.envand set:DB_HOST=mysql DB_NAME=simplyNewsDB DB_USER=root DB_PASS=password APP_ENV=docker ADMIN_DEFAULT_PASSWORD=ChangeMe123!
-
Start Docker:
docker-compose up -d
The startup process handles everything automatically:
- MySQL container starts and waits for readiness
- Web container runs
docker-entrypoint.sh php database/init.phpcreates database, tables, and admin user- Apache starts and app is ready
-
Access the application:
- Web App: http://localhost:8080
- PHPMyAdmin: http://localhost:8081
- Default login:
admin/ChangeMe123! β οΈ Change password immediately! (feature to be implemented)
If you have MySQL installed locally:
-
Clone the repository:
git clone https://github.com/LukaszKwiatkowski94/Simply-news-app.git cd Simply-news-app -
Configure environment variables:
cp example.env .env
Edit
.env:DB_HOST=localhost DB_PORT=3306 DB_NAME=simplyNewsDB DB_USER=root DB_PASS=password APP_ENV=development ADMIN_DEFAULT_PASSWORD=ChangeMe123!
-
Initialize database:
php database/init.php
This script will:
- Create the database
- Create all tables
- Seed the default admin user with password from
ADMIN_DEFAULT_PASSWORD
-
Start the development server:
php -S localhost:8000 index.php
-
Access the application:
- Open http://localhost:8000
- Default login:
admin/ChangeMe123! β οΈ Change password immediately!
When you first start the application, a default admin user is automatically created:
- Username:
admin - Password:
ChangeMe123!(fromADMIN_DEFAULT_PASSWORDenv variable)
-
Change Default Password Immediately
- The default password is
ChangeMe123!fromADMIN_DEFAULT_PASSWORDenv variable - TODO: Application should force password change on first login
- Change it via user profile or database:
php -r "echo password_hash('NewPassword', PASSWORD_DEFAULT);" # Then update in database via PHPMyAdmin or MySQL CLI
- The default password is
-
Creating Additional Admin Users
- Create regular users via signup page
- Grant admin privileges via database:
UPDATE SN_users SET is_admin = 1 WHERE username = 'username';
- Or modify
database/init.phpbefore first run
-
Production Deployment
- Set
APP_ENV=productionto block init.php execution - Initialize database manually before deployment
- Change
ADMIN_DEFAULT_PASSWORDto a strong, unique password - Never commit
.envto version control - Use environment-specific configurations
- Set
The easiest way to run the entire application stack (Web + MySQL + PHPMyAdmin):
-
Configure
.envfile:cp example.env .env
Edit
.env:DB_HOST=mysql DB_NAME=simplyNewsDB DB_USER=root DB_PASS=password APP_ENV=docker ADMIN_DEFAULT_PASSWORD=ChangeMe123!
-
Start all services:
docker-compose up -d
What happens on startup:
- MySQL container initializes
- Web container runs
docker-entrypoint.sh:- Waits for MySQL health check
- Executes
php database/init.php - Creates database and tables
- Seeds admin user with
ADMIN_DEFAULT_PASSWORD - Starts Apache
-
Access the application:
- Simply News App: http://localhost:8080
- PHPMyAdmin: http://localhost:8081
- MySQL: localhost:3306
- Default login:
admin/ChangeMe123!
-
View initialization logs:
docker-compose logs web
Look for "π Simply News App - Database Initialization" section.
-
Stop services:
docker-compose down
-
Rebuild after changes:
docker-compose up -d --build
See DOCKER.md for more detailed Docker documentation and commands.
All sensitive configuration is managed through environment variables in the .env file:
# Database Configuration
DB_HOST=localhost
DB_PORT=3306
DB_NAME=simplyNewsDB
DB_USER=root
DB_PASS=your_password
# Application Settings
APP_ENV=development
ADMIN_DEFAULT_PASSWORD=ChangeMe123!
β οΈ Security Note: Never commit your.envfile to version control. It's listed in.gitignorefor your protection.
| Technology | Purpose | Why It's Great |
|---|---|---|
| PHP 8.1+ | Backend logic | Type hints, match expressions, nullsafe operators |
| MySQL/MariaDB | Data persistence | Reliable, scalable database |
| PDO | Database abstraction | Secure, parameterized queries prevent SQL injection |
| Vanilla JavaScript | Frontend interactivity | No heavy dependencies, lightweight |
| CSS3 | Styling | Modern, responsive design |
| Docker | Containerization | Consistent development & production environments |
This project follows the Model-View-Controller (MVC) pattern:
- Models (
src/Models/) - Database interactions and business logic - Views (
templates/) - User interface templates - Controllers (
src/Controllers/) - Request handling and logic orchestration - Router (
src/Router.php) - Custom HTTP routing without external dependencies
Contributions are welcome! Feel free to:
- Report bugs via GitHub Issues
- Submit feature requests
This project is licensed under the MIT License - see the LICENSE file for details.
- Live Demo: [Coming Soon]
- GitHub Repository: https://github.com/LukaszKwiatkowski94/Simply-news-app
- Author: Εukasz Kwiatkowski
Happy coding! π If you found this project useful, please give it a β on GitHub!