wpdiggerstudio / wpzylos-views
PHP template engine with optional Twig adapter for WPZylos framework
Fund package maintenance!
Paypal
Installs: 234
Dependents: 1
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 0
Open Issues: 0
pkg:composer/wpdiggerstudio/wpzylos-views
Requires
- php: ^8.0
- wpdiggerstudio/wpzylos-core: ^1.0
- wpdiggerstudio/wpzylos-i18n: ^1.0
Requires (Dev)
- phpstan/phpstan: ^1.10
- phpunit/phpunit: ^9.6 || ^10.0
- squizlabs/php_codesniffer: ^3.7
- szepeviktor/phpstan-wordpress: ^1.3
- twig/twig: ^3.0
Suggests
- twig/twig: Required for Twig template engine support
README
PHP template engine with optional Twig adapter for WPZylos framework.
📖 Full Documentation | 🐛 Report Issues
✨ Features
- PHP Templates — Simple PHP-based templates
- Twig Adapter — Optional Twig template engine
- Layouts — Template inheritance
- Sections — Yield and extend sections
- Escaping — Auto-escaping for security
📋 Requirements
| Requirement | Version |
|---|---|
| PHP | ^8.0 |
| WordPress | 6.0+ |
🚀 Installation
composer require wpdiggerstudio/wpzylos-views
📖 Quick Start
use WPZylos\Framework\Views\ViewFactory; $view = new ViewFactory($context); // Render a template echo $view->render('products.index', [ 'products' => $products, ]); // Or use the helper echo view('products.show', ['product' => $product]);
🏗️ Core Features
Basic Templates
// resources/views/products/index.php <ul> <?php foreach ($products as $product): ?> <li><?= esc_html($product->name) ?></li> <?php endforeach; ?> </ul>
Layouts
// resources/views/layouts/app.php <!DOCTYPE html> <html> <head> <title><?= $title ?? 'My Plugin' ?></title> </head> <body> <?= $content ?> </body> </html>
// Extend layout echo $view->render('products.index', [ 'products' => $products, ], 'layouts.app');
Partials
// Include partial <?php include $this->partial('partials.header') ?> // Or using helper <?= view('partials.product-card', ['product' => $product]) ?>
Escaping
// Auto-escaped <?= $this->e($userInput) ?> // Or use WordPress functions <?= esc_html($title) ?> <?= esc_attr($class) ?> <?= esc_url($link) ?>
📦 Related Packages
| Package | Description |
|---|---|
| wpzylos-core | Application foundation |
| wpzylos-routing | URL routing |
| wpzylos-scaffold | Plugin template |
📖 Documentation
For comprehensive documentation, tutorials, and API reference, visit wpzylos.com.
☕ Support the Project
If you find this package helpful, consider buying me a coffee! Your support helps maintain and improve the WPZylos ecosystem.
📄 License
MIT License. See LICENSE for details.
🤝 Contributing
Contributions are welcome! Please see CONTRIBUTING.md for guidelines.
Made with ❤️ by WPDiggerStudio