A complete, production-ready ticket management system built with PHP and Twig templating engine. This application demonstrates full CRUD functionality, authentication, responsive design, and modern UI/UX practices.
- β Landing Page with wavy SVG background and decorative elements
- β Authentication System (Login & Signup) with form validation
- β Dashboard with real-time statistics
- β Complete CRUD Operations for ticket management
- β Form Validation with inline errors and toast notifications
- β Session Management with protected routes
- β Responsive Design (Mobile, Tablet, Desktop)
- β Accessibility Features (ARIA labels, keyboard navigation, focus states)
- π¨ Max-width: 1440px centered layout
- π Wavy SVG background in hero section
- β Decorative circles throughout the site
- π¦ Card-based boxes with shadows and rounded corners
- π― Status-based color coding (Open: Green, In Progress: Amber, Closed: Gray)
- π± Fully responsive across all devices
- Backend: PHP 7.4+
- Templating: Twig 3.x
- Dependency Management: Composer
- Session Handling: PHP Sessions
- Data Storage: JSON file-based (easily upgradeable to database)
- Styling: Pure CSS with CSS Variables
- JavaScript: Vanilla JS (no frameworks)
- PHP 7.4 or higher
- Composer
- Web server (Apache/Nginx) or PHP built-in server
cd c:\Users\User\Desktop\HNG_TEST2\Twigcomposer installIf dependencies are already installed, you can skip this step.
Ensure the data directory is writable:
# On Unix/Linux/Mac
chmod -R 777 data/
# On Windows (PowerShell)
icacls data /grant Users:F /Tphp -S localhost:8000Then open your browser to: http://localhost:8000
Configure your web server to point to the project directory and ensure mod_rewrite is enabled.
Use these credentials to test the authentication:
Admin User:
- Email:
admin@ticketapp.com - Password:
admin123
Regular User:
- Email:
user@ticketapp.com - Password:
user123
Or create your own account via the signup page!
Twig/
βββ index.php # Main application entry point & routing
βββ composer.json # Composer dependencies
βββ .htaccess # Apache URL rewriting
βββ src/
β βββ Router.php # Routing logic
β βββ Session.php # Session management & auth
β βββ TicketManager.php # CRUD operations for tickets
βββ templates/
β βββ layout.twig # Base layout template
β βββ landing.twig # Landing page
β βββ dashboard.twig # Dashboard
β βββ 404.twig # 404 error page
β βββ auth/
β β βββ login.twig # Login page
β β βββ signup.twig # Signup page
β βββ tickets/
β β βββ list.twig # Ticket list
β β βββ create.twig # Create ticket form
β β βββ edit.twig # Edit ticket form
β βββ partials/
β βββ navbar.twig # Navigation bar
β βββ footer.twig # Footer
βββ public/
β βββ css/
β β βββ styles.css # All styling
β βββ js/
β βββ main.js # Client-side JavaScript
βββ data/
βββ tickets.json # Ticket data storage
- Visit the homepage to see the application overview
- Click "Get Started" to create an account
- Click "Login" if you already have an account
- Sign Up: Create a new account with name, email, and password
- Login: Use existing credentials to access the dashboard
- Validation: All forms include real-time validation with helpful error messages
- View ticket statistics (Total, Open, In Progress, Resolved)
- Quick access to all ticket management features
- Logout functionality
- Click "Create Ticket" or "New Ticket"
- Fill in required fields:
- Title (required, 3-200 characters)
- Status (required: open, in_progress, closed)
- Description (optional, max 1000 characters)
- Priority (optional: low, medium, high)
- Submit the form to create the ticket
- See all tickets in a card-based layout
- Each ticket displays:
- Title and description
- Status badge (color-coded)
- Priority badge
- Created and updated timestamps
- Edit and Delete buttons
- Click "Edit" on any ticket
- Modify any field
- Submit to update the ticket
- Click "Delete" on any ticket
- Confirm deletion in the modal
- Ticket is permanently removed
- Primary: #4F46E5 (Indigo)
- Success/Open: #10B981 (Green)
- Warning/In Progress: #F59E0B (Amber)
- Danger/Closed: #6B7280 (Gray)
- Open: Green (#10B981)
- In Progress: Amber (#F59E0B)
- Closed: Gray (#6B7280)
- Max Width: 1440px (centered on larger screens)
- Responsive Breakpoints: 768px (tablet), 480px (mobile)
- Semantic HTML5 elements
- ARIA labels and roles
- Keyboard navigation support
- Focus visible states
- Sufficient color contrast (WCAG AA compliant)
- Screen reader friendly
- Skip to main content link
- Session-based authentication
- Protected routes (Dashboard, Tickets require login)
- Form validation (client-side and server-side)
- XSS protection via Twig auto-escaping
- CSRF protection ready (can be implemented)
- Title: Required, 3-200 characters
- Status: Required, must be one of:
open,in_progress,closed - Description: Optional, max 1000 characters
- Priority: Optional, must be one of:
low,medium,high
- Name: Required (signup only)
- Email: Required, valid email format
- Password: Required, minimum 6 characters
- Confirm Password: Must match password (signup only)
- Displayed beneath form fields
- Red border on invalid inputs
- Clear, actionable error messages
- Success messages (green)
- Error messages (red)
- Warning messages (amber)
- Auto-dismiss after 4 seconds
- Unauthorized access redirects to login
- Session expiry handling
- Clear error messages
- Enable Twig caching in
index.php:'cache' => __DIR__ . '/cache',
- Create a
cachedirectory and set permissions - Set secure session configuration
- Use a real database instead of JSON files
- Implement CSRF protection
- Enable HTTPS
- Set proper error reporting levels
- Implement rate limiting for authentication
- Test all authentication flows (login, signup, logout)
- Create, read, update, delete tickets
- Test form validation with invalid data
- Test responsive design on different devices
- Test keyboard navigation
- Test with screen readers
- Unauthorized Access: Try accessing
/dashboardwithout login - Invalid Login: Use wrong credentials
- Form Validation: Submit empty forms
- Status Validation: Try invalid status values
- Session Management: Logout and try to access protected routes
- Data is stored in JSON files (use a database for production)
- No email verification for signup
- No password reset functionality
- No real-time updates (requires WebSockets)
- Basic authentication (consider OAuth/JWT for production)
- Database integration (MySQL/PostgreSQL)
- Email notifications
- File attachments for tickets
- Comment system
- User roles and permissions
- Advanced search and filtering
- Export tickets (CSV, PDF)
- Dark mode
- Multi-language support
GET /- Landing pageGET /login- Login pagePOST /login- Login submissionGET /signup- Signup pagePOST /signup- Signup submission
GET /dashboard- DashboardGET /tickets- Ticket listGET /tickets/create- Create ticket formPOST /tickets/create- Create ticket submissionGET /tickets/{id}/edit- Edit ticket formPOST /tickets/{id}/update- Update ticket submissionPOST /tickets/{id}/delete- Delete ticketGET /logout- Logout
GET /api/tickets- Get all tickets (JSON)GET /api/stats- Get ticket statistics (JSON)
This is a demo project for HNG. Contributions are welcome!
This project is open source and available under the MIT License.
- Update the form in
templates/tickets/create.twigandedit.twig - Add validation in
src/TicketManager.php::validate() - Update the data structure in
create()andupdate()methods
- Add route in
index.phpusing$router->get()or$router->post() - Create corresponding Twig template
- Add navigation link if needed
- All styles are in
public/css/styles.css - CSS variables for easy theme customization
- Responsive breakpoints defined in media queries
For issues or questions related to HNG Test:
- Review the code and documentation
- Check console for JavaScript errors
- Verify PHP error logs
Built with β€οΈ for HNG Test
TicketFlow - Making ticket management simple and efficient.