Download the PHP package quellabs/canvas-twig without Composer
On this page you can find all versions of the php package quellabs/canvas-twig. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download quellabs/canvas-twig
More information about quellabs/canvas-twig
Files in quellabs/canvas-twig
Package canvas-twig
Short Description Twig template engine integration for the Canvas PHP framework
License MIT
Homepage https://github.com/quellabs/canvas-twig
Informations about the package canvas-twig
Twig Template Engine for Canvas Framework
A Twig template engine implementation for the Canvas PHP framework that provides a consistent interface for template rendering operations.
Features
- Interface Compliance: Implements
TemplateEngineInterfacefor consistent template engine operations - Flexible Configuration: Supports all major Twig configuration options
- Caching Support: Built-in template caching with cache management
- Global Variables: Support for framework-wide template variables
- Custom Extensions: Easy registration of custom functions and filters
- String Templates: Render templates from strings as well as files
- Multiple Template Paths: Support for namespaced template directories
- Debug Mode: Development-friendly debugging and auto-reload features
Installation
Install the package via Composer:
The package includes Twig as a dependency and automatically copies the configuration file to /config/twig.php. No additional setup is required - just register the service provider in your Canvas framework configuration.
Configuration
The package automatically creates a configuration file at config/twig.php during installation.
Selecting the Default Template Engine
To use Twig as the default template engine across your application, set the following in config/app.php:
Once set, rendering templates in your controllers works as normal:
If you need to mix multiple template engines in the same project, you can request a specific engine explicitly via the container:
Error Handling
The template engine provides detailed error messages for common issues:
Performance Considerations
- Enable Caching: Always enable caching in production environments
- Template Compilation: Twig compiles templates to PHP for better performance
- Auto-reload: Disable
auto_reloadin production to avoid file system checks - Cache Warming: Consider pre-compiling templates for optimal performance
Debugging
Enable debug mode during development:
Use the debug function in templates:
Requirements
- PHP 8.2 or higher
- Canvas Framework with TemplateEngineInterface
License
MIT License
Contributing
- Fork the repository
- Create a feature branch
- Add tests for new functionality
- Submit a pull request
Support
For issues specific to this Twig implementation, please check:
- Twig documentation: https://twig.symfony.com/doc/
- Canvas framework documentation
- This implementation's source code comments
All versions of canvas-twig with dependencies
quellabs/dependency-injection Version ^1.
quellabs/contracts Version ^1.
quellabs/sculpt Version ^1.
quellabs/support Version ^1.