-
Notifications
You must be signed in to change notification settings - Fork 0
Home
It looks like I have run out of time, at least for a while, so here is the story. Instead of waiting to find some time for fixing this and that, Iam making it public. Be aware that it's an experimental framework where the goal is to have clean markup in templates.
For the proof ov concept I have just put some code together and it's by no means secure or robust. If it proved to be a good idea then in the feauture I will do the following changes.
- Use Laravel illuminate database component
- Use artisan
- Use a better Router
- Version : 0.1 alpha
- Architecture : MVC
Zema PHP Framework is an experimental Framework; The intention is to keep php code or any templating script away from the view.
By using Zema PHP Framework you can create a GUI in your favorite HTML Framework (Zurb Foundation, Bootstrap etc..) and directly use it in a PHP application (CMS, Blog, web-page etc ..).
If you prefer twig and blade like templates and/or you want to use a PHP Framework for some serious project than you should use Laravel or ...
- Simple
- Easy to use any html templates/GUI
- No need to learn yet another templating language
- Clean URLs
- CRUD actions
- Uses PDO
Views are generated from the html templates/files. The following methods could be used to create the templates.
- Create a template for each view/menu-item e.g. home, about, articles, tutorials, contact etc. and load each whenever needed.
- The benefit of this approach is that you don't need to hide unused partials (See the documentaion) .
- Create one main template then embed tags for all the partials in this main template. Then the partials can be loadded and hidden as needed e.g. if someone clicks on home button, _home.html partial will be rendered and if about is clicked then the _about.html partial will be rendered. Its important to know that in this case you need to hide the unused partials by calling the hide('_some-partial') method. (See the documentaion)
Following is an example of a main template with {_HOME}
, {_ABOUT}
, {_ARTICLE}
, {_ADD-USER-FORM}
, {_LOGIN-FORM}
partials tags.
<!DOCTYPE html>
<head>
<title>Zema CMS Example</title>
</head>
<body>
<div class="row">
<div class="large-10 columns">
{_MAIN-MENU} <!-- This is a partial-tag: will be replaced by _main-menu.html partial -->
</div>
<div class="large-2 columns">
<h4>{ZEMA-USER}</h4> <!-- This is a data-tag: will be replaced by username -->
</div>
<hr/>
</div>
<div class="row">
<div class="large-9 columns" role="content">
<!-- These partial will be loaded/hidden from a controller -->
{_HOME}
{_ARTICLE}
{_LOGIN-FORM}
</div>
<div class="large-3 columns"></div>
</div>
<footer class="row"> </footer>
<script src="{ZEMA_ROOT}/js/app.js"></script>
</body>
</html>
The following is the _main-menu.html
partial in views\partials\ folder. The {_MAIN-MENU}
partial-tag in the
above main.html template will be replaced by this partial.
This partial contains a {ZEMA-MAIN-MENU}
Tag which will be replaced by a list of menu items.
Read about tags in the (documentaion)
<div class="nav-bar right">
<ul class="button-group">
{ZEMA-MAIN-MENU}
</ul>
</div>
-
Lists and Menus
As opposed to other php frameworks, data is not sent from the controller to the template, instead the data is prepared in the controller e.g. lists and menus are generated at back-end
For Example
<?php
$menu = $this->make($titles, 'a', 'href = #')->get();
Where $titles is an array of some titles, Will generate something like the following
<a href="#">Foo</a>
<a href="#">Bar</a>
This anchor tag can then be wrapped in any other tag e.g li, or inner and outer tags like td wrapped in tr etc.
For example:
<?php
$menu->addTag('td')->addTag('tr');
The ZEMA_TAG which will be used in the template kan then be set with the value of $menu. For example the aside_menu is set like this
<?php
$this->setTag(TAGS['aside_menu'], $menu);
which can then be used in the template as follows.
<table>
{ZEMA-ASIDE-MENU}
</table>
OR if li is added to the menu items then {ZEMA-ASIDE-MENU} will be use inside
<ul class="menu">
{ZEMA-ASIDE-MENU}
</ul>
You have full controll over tags. You can define your own TAGS in the config file.
-
Classes and IDs
As the lists and Menu items are generated by back-end therefore ID's, css classes and other attributes, to inner html-tags, can only be added from within controllers. e.g. on an
- tag or an achor tag
<?php
$menu = $this->make($titles, 'a', 'class = "someClass" href = "#"');
This will generate something like the following where class="myclass" attribute is added to the anchor tag:
<a class="someClass" href="#">Zema PHP framework</a>
-
Extra buttons
To create buttons (e.g edit and/or delete buttons) for each item in a list generated by Back-end then those buttons should be created at back-end and add them to the menu items. See (documentaion)
Zema PHP Framework uses clean REST style URIs.
http://localhost/zemacms/public/{resource name}/{id}
Example: To get article by id: http://localhost/zemacms/public/articles/1
Zema PHP Framework has a basic scaffolding which can generate controllers, models, view-templates and a full application.
creating a model
php make.php model article
creating a controller
php make.php controller articles
creating a view-template
php make.php view main
creating an entire application with model, controller and view-template
php make.php app
- Minimum PHP version 7
- Nothing yet
Mohammad Homayoon Fayez
mhfayez at hot mail dot com
hmmm!!! It means "My" in Pashto, spoken in Afghanistan. So, Zema PHP Framework means My PHP Framework and Zema CMS means My CMS