bomi / mvcat
There is no license information available for the latest version (v3.0.0) of this package.
shared library for ME
v3.0.0
2025-03-14 13:49 UTC
Requires
- php: >=8.2
- symfony/mailer: ^7.2
- vlucas/phpdotenv: ^5.6
README
MVC@PHP
library
Demo
- see: DEMO
- url: localhost/mvcat/demo
Composer
composer require bomi/mvcat
Using
use bomi\mvcat\service\Mvcat; require_once '../libs/vendor/autoload.php'; $language = "de"; // or your implementation to find a language Mvcat::build("manifest.json") ->language($language) ->execute(function(int $code, Exception $exception = null){ if ($code !== 200) { echo $exception->getMessage(); } });
.htaccess
- see
- change line to your base url
RewriteBase /mvcat/demo/
Configuration file
Manifest.json
{ "globals" : { "baseurl" : "/mvcat/demo/", "asserts" : "public/asserts/" }, "routing" : { "views": "public/views/", "controllers": "bomi/mvcat/demo/classes/controllers/", "routes" : [ { "path": "/", "parameters": { "controller" : "home", "action": "index" } },{ "path": "users/{id:\\d+}", "methods" : ["GET"], "parameters": { "controller" : "User", "action": "user" } } ] }, "templates" : [ { "name" : "main", "path" : "public/templates/main.phtml" } ], "data" : { "connection" : { "host" : "", "dbname" : "", "username" : "", "password" : "", "additional" : { "key" : "value" } }, "repositories" : { "user" : "bomi/mvcat/demo/classes/repositories/UserRepository" } }, "i18n" : { "default" : "public/i18n/lang-de.properties", "languages" : { "ru" : "public/i18n/lang-ru.properties" } } }
Call view in template
- see: main.phtml
echo ${View::VIEW_RENDER};
- use template
echo $this->view("users/form.inc", $params, "main");
- render view without tepmplate
echo $this->view("users/form.inc", $params);
Controller
- your controller should inherit the bomi\mvcat\base\Controller
- example
- fetch request information
$this->getRequestContext()->getMethod(); // POST, GET, PUT, DELETE, OPTIONS $this->getRequestContext()->getPostData; // post data $this->getRequestContext()->getGetData; // get data
Languages
- define your languages in *.properties file. example
- add paths to manifest.json
- use in template or view:
- Without arguments ${key}
- With arguments ${key>>arg1,arg2,arg3}
- use in constructor
- $this->_i18n->get("key", ["arg1, arg2"]);