Introduce
A simple introduce to SinglePHP,directoies struct and Hello World
A simple introduce to SinglePHP,directoies struct and Hello World
SinglePHP is a single file PHP framework, developed for simple php website development, with a simple router and use raw php syntax as page template instead of shit template engine, and the widget component is simple and powerful.
SinglePHP is developed by leo108, you can fork the project at Github and make pull requests.
Zip file from github
use git clone, the master branch is stable version, the develop branch may contains some experiment feature.
git clone https://github.com/leo108/SinglePHP.git
├── App #application directoy
│ ├── Controller #Controller folder
│ │ └── IndexController.class.php
│ ├── Lib #other libs
│ ├── Log #log folder, should be writable
│ ├── View #template folder
│ │ ├── Index #IndexController's template folder
│ │ │ └── Index.php
│ │ └── Public
│ │ ├── footer.php
│ │ └── header.php
│ ├── Widget #widget folder
│ │ ├── MenuWidget.class.php
│ │ └── Tpl #widget template folder
│ │ └── MenuWidget.php
│ └── common.php #common functions
├── SinglePHP.class.php #SinglePHP core
└── index.php #the entrance file
3-files hello world
Entrance file: index.php
<?php
include './SinglePHP.class.php'; //include the SinglePHP
$config = array('APP_PATH' => './App/'); //Set the application directoy to "./App/"
SinglePHP::getInstance($config)->run(); //go go go!
Default Controller: App/Controller/IndexController.class.php
<?php
class IndexController extends Controller { //Controller
public function IndexAction(){ //Default Action
$this->assign('content', 'Hello World'); //set the template variant 'content' to 'Hello World'
$this->display(); //render and display
}
}
Template file: App/View/Index/Index.php
<?php echo $content;
Visit index.php, it should print
Hello World