A modern, modular, user-friendly PurePHP WebKit with auto-discovered routing, authentication, API, admin features, and more.
- Auto-discovered routing for pages and APIs
- SQLite/MySQL support with .env configuration
- Modular authentication with registration, login, password reset
- Role-based permissions (admin/user roles)
- Intended URL redirect after login/registration
- Dynamic layout system with admin-controlled theme selection
- CSRF protection on all forms
- Flash messages for user feedback
- Input validation and sanitization
- Rate limiting and security headers
- File upload with audit logging
- Admin audit log viewer for monitoring
- REST API with token authentication
- CLI utilities (database backup, migrations)
- Internationalization (i18n) support
- Caching and logging utilities
- Modern, accessible UI with dark mode support
- Responsive design for all devices
- Easy to extend and maintain
- Clone or download the repository
- Install dependencies:
composer install
- Configure environment:
cp .env.example .env # Edit .env with your database and site settings
- Set up the database:
php system/migrate.php
- Start development server:
php -S localhost:8000 -t public/
- Visit
http://localhost:8000
in your browser
├── public/ # Web root (document root)
│ ├── assets/ # CSS, JS, images
│ ├── pages/ # Public pages (auto-routed)
│ └── api/ # API endpoints
├── app/ # Application code
│ ├── templates/ # Layouts and views
│ ├── Controllers/ # Business logic
│ └── data/ # SQLite DB and logs
├── system/ # Core framework
│ ├── auth.php # Authentication helpers
│ ├── db.php # Database abstraction
│ ├── router.php # Auto-routing system
│ └── migrate.php # Database migrations
├── api/ # API endpoints
├── cli/ # Command-line utilities
├── config/ # Configuration files
├── db_changes/ # Database migration scripts
├── tests/ # Test suite
└── vendor/ # Composer dependencies
PurePHP WebKit supports both SQLite (default) and MySQL:
DB_DRIVER=sqlite
DB_PATH="app/data/app.db"
DB_DRIVER=mysql
DB_HOST=localhost
DB_NAME=your_database
DB_USER=your_username
DB_PASS=your_password
Run migrations after configuring:
php system/migrate.php
- User registration and login
- Password reset functionality
- Role-based access control (admin/user)
- CSRF protection on all forms
- Secure session management
- Password strength validation
- 4 built-in layouts: Default, Sidebar, Centered, Full-width
- Admin-controlled: Only administrators can change layouts
- Responsive design: Works on all screen sizes
- Dynamic switching: Changes apply immediately
- Admin dashboard with system overview
- Audit log viewer for monitoring user actions
- User management capabilities
- Layout customization controls
- System settings management
- REST API with Bearer token authentication
- Health check endpoint for monitoring
- API documentation page
- File upload with security validation
- Rate limiting protection
- Auto-routing: Just add PHP files, routes are created automatically
- PSR-4 autoloading with Composer
- Modular architecture: Easy to extend and customize
- Comprehensive testing suite
- Development/production modes
- Error logging and debugging tools
Add public/pages/about.php
:
<?php
$title = 'About Us';
ob_start();
?>
<h1>About Our Application</h1>
<p>Welcome to our PurePHP WebKit!</p>
<?php
$content = ob_get_clean();
include __DIR__ . '/../../app/templates/layout.php';
Visit /about
- the page is automatically routed!
<?php
require_login(); // Require authentication
$title = 'Dashboard';
ob_start();
// Your page content here
$content = ob_get_clean();
include __DIR__ . '/../../app/templates/layout.php';
Add api/endpoints/users.php
:
<?php
require_once '../../../system/api_auth.php';
api_authenticate(); // Require API token
header('Content-Type: application/json');
echo json_encode(['users' => get_all_users()]);
- ✅ Never commit
.env
or database files - ✅ Use HTTPS in production
- ✅ Set strong permissions on sensitive folders
- ✅ Change default tokens before deployment
- ✅ Enable production mode for live sites
- ✅ Regular security updates of dependencies
- PHP 7.4+ (8.0+ recommended)
- Composer for dependency management
- SQLite or MySQL database
- Web server (Apache/Nginx) or PHP built-in server
Run the test suite:
php run_tests.php
Add tests for new features in the tests/
directory.
- GUIDE.md - Complete technical documentation
- PRODUCTION_CHECKLIST.md - Deployment checklist
- CHANGELOG.md - Version history and changes
- CONTRIBUTING.md - Contribution guidelines
- API Documentation - Visit
/api-docs.php
in your application
We welcome contributions! Please see our contributing guidelines for details.
MIT License - see composer.json for details.
- 📖 Documentation: GUIDE.md
- 🐛 Issues: GitHub Issues
- 💬 Discussions: GitHub Discussions
Ready to build something amazing? 🚀
PurePHP WebKit provides a solid foundation for modern PHP applications with security, scalability, and developer experience in mind.