master php framework
1.0.0
框架 ?
這個由總體規劃精心設計的PHP框架旨在使香草PHP開發人員擁有對項目的控制和責任。您可以在GitHub上找到有關Masterplan的更多信息。
這不僅僅是另一個框架!對於那些喜歡深入研究項目的人來說,這種項目結構非常適合您。它提供了數據庫及以後的可自定義選項。為什麼不嘗試一下?
哦,我忘了提到,託管輕而易舉。只需將您的項目部署到服務器的根目錄,而Bloom?它已經託管了!
首先,我們需要定義頁面路由。路線位於app/routes/route.php中。該route是Bootstrap文件之一,因此您無需創建它。
// app/routes/route.php
$ routes = [
' / ' => ' indexController ' ,
];我們定義了路由'/',並將控制器名稱作為indexController 。現在,我們需要在app/controllers目錄上創建控制器文件,因此我們將在app/controllers目錄中創建名為indexController.php的文件。
<?php
// app/controllers/indexController.php
// Change this to your twig directory
// Its instance is at '/views/'
$ twig_dir = ' /home/ ' ; // meaning /views/home/
// Don't change this!
require_once __DIR__ . ' /../Helpers/twig.php ' ;
// Load the Twig template
$ template = $ twig -> load ( ' HelloWorld.twig ' );
// add your custom variable either from database or your own
$ title = " Hello World Website! " ;
// Render the template with variables
echo $ template -> render ([
' title ' => $ title ,
// add more as you want
]);現在,如您所見,我們需要創建一個名為helloworld.twig的文件views/home/ 。為了澄清,我將樹枝用作HTML和PHP變量/數組的渲染器。
{# views/home/HelloWorld.twig #}
<!DOCTYPE html>
< html lang = " en " >
< head >
< meta charset = " UTF-8 " >
< title >{{ title }}</ title >
{# assume you have a style at /public/css/style.css #}
< link rel = ' stylesheet ' href = ' /public/css/devices.min.css ' >< link rel = " stylesheet " href = " /public/css/style.css " >
</ head >
< body >
< h1 align = " center " > Hellow World! </ h1 >
{# also lets assume you have scipt file at '/public/js/script', remember to add '/' before 'public/js/script' #}
< script src = ' /public/js/moment.min.js ' ></ script > < script src = " /public/js/script.js " ></ script >
</ body >
</ html >如前所述,該框架是針對那些尋求控制自己項目的人( Vanilla PHP )量身定制的。運行服務器與Vanilla PHP相同。
Just put your files on your favorite server and run the server!
php -S localhost:8080 Simply place your files in your server's root directory, typically inside '/public/www/'.
項目變量可在此處找到app/project.php ,您可以在這裡放置項目名稱,聯繫人,顯示項目是否是開發/生產/維護,數據庫連接以及許多..
我無法介紹這裡的所有復雜性,我發表了很多評論,以使您的生活更輕鬆。我也強烈建議香草PHP開發人員擁有最好的體驗。
我熱切地等待著您的拉力請求。如果您有任何想法或邏輯可以在此框架中實施,那麼您會受到熱烈歡迎!
麻省理工學院