symprowire/symprowire

a PHP MVC Framework for the ProcessWire CMS/CMF

v0.10.0 2021-12-31 15:23 UTC

README

a PHP MVC Framework for ProcessWire

Features

  • Template rendering in a MVC Pattern (done)
  • ProcessWire as a Service (done)
  • Twig as optional Template Engine (not ready)
  • Symfony Dependency Injection / Container (done)
  • Symfony Controller Resolver based on the Template (done)
  • PHPUnit as a Testsuite (done)

How does it work?

Symprowire offers a structured way to render your ProcessWire files and compose your data. Symprowire implements the Symfony/HttpFoundation and handles the template rendering in a Request - Process - Response workflow. This extends Symprowire driven templates with the following features

  • Twig
  • Dependency Injection
  • EventDispatcher

Symprowire integrates fully with ProcessWire and does not alter the Core in any way. To use Symprowire, even in your existing sites, you just have to copy the controller template file.

Symprowire Routing - Template matching

Symprowire will generate his routing based on the available ProcessWire Templates. The runtime scans every Template for the alternative Templatefile "controller". This will add a /$template->name route to the RouteCollection which will always resolve to a Controller::index action. To add new Views to your Template you either provide a _sympro=$method GET Parameter to your URL or you use Route Annotations.

Requirements

  1. composer
  2. fresh installed ProcessWire 3.x
  3. PHP >=8.0.2

Installation

Symprowire gets called via Template file by ProcessWire and will be processed by page->render().

  1. Download ProcessWire 3.x from the ProcessWire Homepage
  2. Install ProcessWire with debug mode enabled and setup your Environment
  3. Now open up the /site folder in the Terminal of your liking
  4. Init your Project with composer init and follow the instructions
  5. composer require symprowire/symprowire
  6. composer install
  7. copy vendor/symprowire/symprowire/templates/controller.php into your templates folder
  8. change the Alternative Templatefile to 'controller'
  9. Make sure that $config->appendTemplateFile and $config->prependTemplateFile are disabled

You have to follow PSR-4 naming conventions and have to use site/src for your App in composer.json

Running Tests in Develop

php bin/phpunit

Recommended Modules

  • Tracy Debugger

Error Code Levels

  • 100 -> Request // Errors thrown during Request creation
  • 200 -> SymproWireEngine // Errors from the Kernel
  • 300 -> SymprowireController // Userland
  • 400 -> SymprowireService // Error Code Level for Services