1. Go to this page and download the library: Download pleonovich/simcore library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
class Userlist extends Model {
protected static $table = 'userslist';
}
class Userlist extends Model {
protected static $table = 'userslist';
protected static function schema($create) {
$create
->id()
->varchar('user_name')
->varchar('user_login')
->varchar('email')
->text('secret')
->int('manager')
->int('moderator');
}
}
Userlist::migrate();
class Userlist extends Model {
protected static $table = 'userslist';
protected static function insert($insert) {
$insert
->set('user_name', 'Admin')
->set('user_login', 'admin')
->set('secret', '12345')
->set('manager', '1')
->set('moderator', '1');
}
}
Userlist::insertData();
// returns all data from table
Array all ()
// returns only specific columns from table
Array getNames ( mix ... )
// returns one specific column
Array column ( string $name )
// return one specific row by id
Array getById ( int $id )
// return one row by id specific column and its value
Array getByValue ( string $name, string $value )
// return specific rows by id specific column and its value
Array namesByValue ( Array $names, string $name, string $value )
// updates data in db from POST, inserts if id not exist.
Boolean save ()
// removes data by id
Boolean remove ( string $name, string $value )
Model
class IndexController {
public function Index () {
$data = Pages::getById(7);
print_r($data);
}
}
{{
#src/views/layout.view.php
<h1>Title</h1>
{{}
{{block content}}
<p>Here some text</p>
{{/block content}}
class Controller extends abstractController {
protected $title;
protected $content;
public function __construct () {
parent::__construct();
}
// PAGE WHEN ACCESS DENIED
protected function accessDenied () {
View::factory()->render('accessdenied');
}
// PAGE FOR 404
protected function action404 () {
View::factory()->render('action404');
}
// LAYOUT VIEW
protected function render () {
View::factory()
->bind("title",$this->title)
->bind("content",$this->content)
->render('layout'); // view name without prefix
}
}
class IndexController extends Controller {
public function Index () {
$this->title = "Hello world!";
$this->content = "Here is some text for our first page";
// MAIN RENDER
$this->render();
}
}
/simcore/config/Config.class.php
index.php
Model.class.php
layout.view.php
html
// Set variables
{{var myvar='hello'}}
//The same as:
$name='hello'
html
{{foreach $array as $one}}
<p>{{$one}}</p>
{{/foreach}}
// The same as:
foreach ($array as $one):
html
{{for ($a=1;$a<7;$a++)}}
<p>{{$a}}</p>
{{/for}}
// The same as:
for($a=1;$a<7;$a++):
html
{{if $var}}
<p>true</p>
{{else}}
<p>false</p>
{{/if}}
// The same as:
if($var):
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.