DelphiMVCFramework comes with 40+ sample projects that demonstrate all framework features. Each sample is self-contained and focuses on specific functionality.
All samples are located in the samples/ directory. Each sample is a complete, runnable project that demonstrates specific features of the framework.
Location: samples/hello_world/
The simplest possible DMVCFramework server demonstrating basic setup and routing.
Location: samples/renders/
Comprehensive demonstration of all rendering capabilities:
- Object serialization
- List rendering
- Dataset to JSON conversion
- Custom serialization attributes
- HATEOAS support
Location: samples/function_actions_showcase/
Demonstrates the new functional actions feature where functions can be used as controller actions:
[MVCPath('/sum/($A)/($B)')]
function GetSum(const A, B: Integer): Integer;
[MVCPath('/person')]
function GetPerson: TPerson;Location: samples/middleware_cors/
Cross-Origin Resource Sharing configuration and handling.
Location: samples/middleware_staticfiles/
Serving static content and SPA applications:
- File serving configuration
- SPA routing support
- Custom file filtering
- Security considerations
Location: samples/middleware_jwtblacklist/
JWT token blacklisting and logout functionality for JWT-based authentication.
Location: samples/middleware_analytics/
API usage analytics with automatic CSV generation for monitoring and analysis.
Location: samples/middleware_compression/
Response compression with gzip and deflate support.
Location: samples/activerecord_showcase/
Complete demonstration of the MVCActiveRecord ORM:
- Entity mapping and attributes
- CRUD operations
- RQL queries
- Relationships
- Validation
- Nullable types
- Connection management
Location: samples/activerecord_crud/
RESTful CRUD operations using MVCActiveRecord with automatic endpoint generation.
Location: samples/articles_crud_vcl_client_meta/
VCL client application demonstrating metadata-driven dataset initialization and JSON data loading.
Location: samples/jsonrpc_with_published_objects/
Complete JSON-RPC 2.0 implementation:
- Exposing regular Delphi objects
- Automatic method publishing
- Async JSON-RPC calls (new feature)
- Parameter marshalling
- Error handling
Basic JSON-RPC server implementation with method calls and notifications.
Location: samples/jsonwebtoken/
Complete JWT implementation:
- Token generation and validation
- Claims handling
- Token expiration
- Authentication middleware
HTTP Basic Authentication implementation with custom authentication handlers.
Implementing custom authentication schemes and authorization logic.
Location: samples/serversideviews_mustache/
Server-side rendering using Mustache templating engine:
- Template syntax
- Partial templates
- Data binding
- Dynamic content generation
Location: samples/serversideviews_lua/
Server-side view support using eLua scripting engine (requires Lua DLLs).
Advanced templating with TemplatePro engine for complex template scenarios.
Location: samples/serversentevents/
Real-time push notifications using Server-Sent Events:
- Event streaming
- Connection management
- Real-time updates
- Client-server communication
Location: samples/fileupload/
File handling operations:
- Multipart form data handling
- File upload processing
- Progress tracking
- Security considerations
Location: samples/htmx/
HTMX server-side support through MVCFramework.HTMX.pas:
- HTMX request handling
- Dynamic content updates
- Server-side rendering for HTMX
Location: samples/profiling/
Built-in profiler demonstration:
procedure ProfiledAction;
begin
begin var Prof := Profiler.Start('DataProcessing');
ProcessData();
end; // Automatically logged
end;Location: samples/renders_spring4d_nullables/
Support for Spring4D nullable types in serialization and rendering.
Location: samples/custom_exception_handling/
Implementing custom exception handling mechanisms for better error management.
Advanced entity processing and validation with lifecycle hooks and business rules.
Location: samples/avoid_mid_air_collisions_sample/
Demonstrates ETag-based conflict detection and resolution for safe concurrent updates.
Location: samples/swagger_api_versioning_primer/
API versioning strategies with Swagger/OpenAPI documentation.
Implementing custom serialization logic for complex data types.
Demonstrates packaging DMVCFramework server as a Windows DLL.
Running DMVCFramework applications as Linux daemons with proper signal handling.
Deploying DMVCFramework applications as Apache modules.
Demonstrates the built-in REST client capabilities:
- HTTP method support
- Authentication
- Response handling
- Error management
Desktop client applications consuming DMVCFramework APIs.
- DelphiMVCFramework installed and configured
- Appropriate Delphi version (see compatibility matrix)
- Database connections configured (for database samples)
- Navigate to the desired sample directory
- Open the project file (.dproj) in Delphi
- Configure database connections if required (check documentation in sample)
- Compile and run (F9)
- Test the endpoints using browser, Postman, or provided client
Some samples require database setup. Connection configurations are typically found in:
- Configuration files within the sample directory
- WebModule creation procedures
- Dedicated database setup units
Common databases used in samples:
- PostgreSQL - Full feature samples
- SQLite - Embedded database samples
- Firebird - Cross-platform samples
- MySQL/MariaDB - Alternative SQL database samples
Web Browser: For simple GET requests and web interfaces
http://localhost:8080/api/hello
http://localhost:8080/api/customers
Postman/Insomnia: For comprehensive REST API testing with different HTTP methods
curl: Command-line testing
curl -X GET http://localhost:8080/api/customers
curl -X POST http://localhost:8080/api/customers -H "Content-Type: application/json" -d '{"name":"John Doe"}'Built-in Swagger UI: Many samples include automatic API documentation
http://localhost:8080/api/system/describeserver.info
- hello_world - Basic framework concepts
- renders - Data serialization and response handling
- middleware_staticfiles - Static content serving
- jsonwebtoken - Basic authentication
- activerecord_showcase - ORM and database integration
- jsonrpc_with_published_objects - JSON-RPC services
- serversideviews_mustache - Server-side rendering
- serversentevents - Real-time features
- custom_exception_handling - Error handling strategies
- profiling - Performance optimization
- middleware_jwtblacklist - Advanced security
- htmx - Modern web development patterns
Each sample includes:
- README.md - Setup instructions and feature explanation
- Complete source code - Fully functional project
- Database scripts (if needed) - Setup and sample data
- Documentation comments - Code explanation
- Configuration examples - Different deployment scenarios
sample_name/
├── README.md # Setup and usage instructions
├── ProjectName.dpr # Main project file
├── ProjectName.dproj # Delphi project file
├── WebModuleU.pas # Web module with configuration
├── ControllerU.pas # Sample controller(s)
├── EntityU.pas # Data models (if applicable)
├── templates/ # Template files (if applicable)
├── www/ # Static files (if applicable)
└── sql/ # Database scripts (if applicable)
- Start Simple: Begin with hello_world and gradually progress to more complex samples
- Read Documentation: Each sample has specific setup requirements
- Database Configuration: Check connection strings and database requirements
- Port Conflicts: Default port is usually 8080, change if needed
- Dependencies: Some samples require additional libraries or services
- Learning Approach: Study the code, modify it, experiment with changes
Port Already in Use
Change the port in the main program file or WebModule configuration
Database Connection Errors
Verify connection strings, database server status, and credentials
Missing Dependencies
Check if additional libraries or services are required (Redis, specific database drivers, etc.)
Compilation Errors
Ensure all library paths are correctly configured in Delphi IDE
| Category | Sample Count | Key Features |
|---|---|---|
| Core Framework | 5+ | Basic setup, routing, rendering |
| Middleware | 8+ | CORS, authentication, static files, compression |
| Database/ORM | 6+ | ActiveRecord, CRUD, multiple databases |
| JSON-RPC | 3+ | RPC services, async calls, object publishing |
| Security | 4+ | JWT, Basic Auth, custom authentication |
| Views/Templates | 3+ | Mustache, eLua, TemplatePro |
| Advanced Features | 10+ | SSE, profiling, HTMX, file handling |
| Client Applications | 3+ | REST clients, VCL applications |
| Platform Specific | 4+ | DLL, Linux, Apache module |
📚 Remember: Each sample is designed to be educational and practical. Use them as starting points for your own applications and don't hesitate to modify and experiment with the code to better understand the framework's capabilities.