- speed - Quetzal is lightweight and every component of it get own job fast and get in done
- no dependencies (*except Symphony/yaml)
- easy and fast configuration
- PHP ≥ 7.3
- Composer
git clone https://github.com/VoodooPrograms/our-framework.git
composer create-project quetzal/quetzal-mvc
TBD
.
├── Config
│ ├── env.yaml
│ ├── routing.yaml
│ └── settings.yaml
├── Core
├── index.php
├── User
│ ├── Controllers
│ ├── Models
│ └── Services
│ └── Templates
└── vendor
description:
Config- place where all configuration files are storedenv.yaml- environment variablesrouting.yaml- routing table with all available pathssettings.yaml- main configuration fi eCore- heart of quetzal framework with all logic. Framework users don't have to bother what is thereindex.php- runner of quetzal-mvcUser- place where all user dependend files are storedvendor- composer related binaries
TBD
TBD
TBD
The main porpuse of routing module is to run proper controller of given URL.
| Use case | expression | URL |
|---|---|---|
| Explicit | /blog/art |
/blog/art |
| Key-word | /blog/art/{Number} /blog/art/{String} |
/blog/art/69 /blog/art/JohhnyBravo |
| Asterisk | /blog/* /blog/user/* |
/blog/main /blog/user/* |
| Mixed | /blog/page/{Number}/* |
/blog/page/69/since_ive_been_loving_u |
What does it mean?
In the routing.yaml file we have routing section where we define our routes. Route name must be unique and should be descriptive. Every route has a path and action parameter. Path is responsible for matching correct url, when action job is to trigger correct action within a controller.
routing.yaml:
routing:
homepage:
path: /
action: Ourframework\User\Controllers\SimpleController
blog:
path: /blog
action: Ourframework\User\Controllers\BlogController
blog_article:
path: /blog/art
action: Ourframework\User\Controllers\ArticleController
blog_page:
path: /blog/page/{Number}
action: Ourframework\User\Controllers\ArticleController
blog_page_string:
path: /blog/page/{String}
action: Ourframework\User\Controllers\ArticleController
blog_mixed:
path: /blog/art/*/{String}
action: Ourframework\User\Controllers\ArticleControllerExternal template engines
Currently supported external template engines in our framework:
- Twig
- Bladeone
- Smarty
| Engine Name | settings.yaml |
File Extension | Link |
|---|---|---|---|
| Twig | engine: ['twig'] | .html.twig |
https://twig.symfony.com/doc/2.x/intro.html |
| Bladone | engine: ['blade'] | .blade.php |
https://github.com/EFTEC/BladeOne#install-pick-one-of-the-next-one |
| Smarty | engine: ['smarty'] | .tpl |
https://www.smarty.net/quick_install |
Composer is required to install all engines https://getcomposer.org/download/
*Twig installation
composer require "twig/twig:^2.0"
*Bladeone installation
composer require eftec/bladeone
*Smarty installation
composer require smarty/smarty
To change template enging you should edit Config/settings.yaml file
settings.yaml:
template:
engine: ['smarty'] # or twig, blade, smarty etc.3.1 Twig Controller Code
class TwigController extends Controller
{
public function index(Request $request)
{
$name='Bob';
$this->render('example_template.html.twig', ["name" => $name]);
}
}example_template.html.twig:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<p>Hello {{name}}, welcome to Twig!</p>
</body>
</html>3.2 Bladeone Controller Code
class BladeoneController extends Controller
{
public function index(Request $request)
{
$name='Bob';
$this->run('example_template.blade.php', ["name" => $name]);
}
}example_template.blade.php:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<p>Hello {{$name}}, welcome to Bladeone!</p>
</body>
</html>4.3 Smarty Controller Code
class SmartyController extends Controller
{
public function index(Request $request)
{
$name='Bob';
$this->display('example_template.tpl', ["name" => $name]);
}
}example_template.tpl:
Hello {$name}, welcome to Smarty!
