This is a demo/example application showcasing the capabilities of avoutic/web-framework. It demonstrates real-world usage of the framework's core features including authentication, user management, templating, and more.
This demo app showcases the following WebFramework capabilities:
-
Authentication & User Management
- User registration with email verification
- Login/logout functionality
- Password reset flow
- Email change with verification
- Password change
- Session management
-
Security Features
- CSRF protection
- Security headers middleware
- Input validation
- Password hashing and validation
-
Templating
- Latte template engine integration
- Template inheritance
- Message display system
-
Email Integration
- Postmark email service integration
- Verification code emails
- Transactional email sending
-
Database/ORM
- Entity/Repository pattern
- CRUD operations (Create, Read, Update, Delete)
- Database migrations
- Entity collections
- Foreign key relationships
-
Infrastructure
- Database integration (MySQL/MariaDB)
- Redis caching
- Dependency injection
- Middleware stack
- Route management
- Custom console tasks
Clone this repository and install dependencies:
git clone <repository-url>
cd web-framework-example-app
composer installNote: This is a demo application. For starting a new project, use the skeleton:
composer create-project avoutic/web-framework-skeleton my-projectStart the MariaDB database and Redis cache using Docker:
docker-compose up -dThe database will be available at localhost:3399 and the Redis server will be available at localhost:3400.
Important: Configuration files in config/auth/ contain sensitive information. If you're using env() statements, you can safely commit them. Otherwise, add config/auth/ to .gitignore.
This demo app uses Postmark for sending emails (verification codes, password resets, etc.).
-
Get a Postmark API Key:
- Sign up at https://account.postmarkapp.com/sign_up
- Create a server and get your API key from the server settings
-
Configure the API Key:
- Edit
config/auth/postmark.phpand set your API key:return env('POSTMARK_API_KEY', 'your-actual-api-key-here');
- Or set the
POSTMARK_API_KEYenvironment variable in the.envfile
- Edit
-
Configure Sender Email:
- Edit
config/config.phpand update thesender_core.default_senderandsender_core.assert_recipientvalues - Or set the
POSTMARK_SENDER_EMAILandASSERT_RECIPIENT_EMAILenvironment variables in the.envfile - Important: The sender email must be verified in your Postmark account
- Edit
This demo includes a custom AppRenderService that automatically:
- Includes messages from
MessageServicein all templates - Provides CSRF tokens to templates
- Includes base URL for template use
This demonstrates how to extend the framework's rendering capabilities.
This demo includes a custom console task posts:stats that displays statistics about posts in the database. This demonstrates how to:
- Create custom console tasks by extending
ConsoleTask - Register tasks in the
console_tasksconfiguration - Use dependency injection in console tasks
- Access repositories and display formatted output
Run it with:
php framework posts:stats-
Start the database and cache:
docker-compose up -d
-
Check database status and run migrations:
php framework db:status php framework db:migrate
This will create the
poststable needed for the Database/ORM demo. -
Run sanity checks:
php framework sanity:check
-
Try the custom console task:
php framework posts:stats
This demonstrates how to create custom console tasks in WebFramework.
-
Configure Postmark (see Configuration section above)
Start the development server:
php -S localhost:8000 public/index.phpThen access the demo application at http://localhost:8000.
Once running, you can:
- Register a new account - See the registration flow with email verification
- Login - Experience the authentication system
- View your profile - See authenticated user information
- Change password - Test password management
- Change email - See email verification flow
- Reset password - Try the password reset functionality
- Create and manage posts - See Database/ORM capabilities with full CRUD operations
All forms include validation, CSRF protection, and user-friendly error messages.
This demo also demonstrates the following capabilities:
- Database/ORM
- Multi-language support with translation files
- Logging
- Event Dispatching and Listening
- Custom console tasks (see
posts:statscommand)
actions/- Action classes handling HTTP requestsroutes/- Route definitions (Authenticated and Unauthenticated)templates/- Latte templates with base layoutsrc/- Application code including custom servicesconfig/- Configuration filesdefinitions/- Dependency injection definitionsmigrations/- Database migrations
For detailed documentation about WebFramework, visit: