Simple and fast PHP framework delivered as C-extension.
You don't need learn or use the C language, since the functionality is exposed as PHP classes ready for you to use.
Database connection
We are trying to create one syntax for PDO & Mongo to connect to databases.
Working with db:$users = $this->db->find(
'users',
[
"status" => 1,
"age" => [">" => 21]
],
[
"limit" => 20
]
);
foreach ($users as $user) {
echo $user['username'];
}
Working with model: $users = Users::find(
[
"status" => 1,
"age" => [">" => 21]
],
[
"limit" => 20
]
);
foreach ($users as $user) {
echo $user->username;
}
Example of action: /**
* Display the specified post
*/
public function showAction()
{
$params = $this->router->getParams();
$id = $params['id'];
if ($post = Posts::findOne($id)) {
$this->tag->setTitle($post->title);
$this->view->setVars([
'post' => $post,
'user' => $post->getUser(),
'comments' => $post->getComments(),
]);
} else {
parent:notFound();
}
}
Example of validation: $validation = new Ice\Validation();
$validation->rules([
'fullName' => 'required',
'email' => 'required|email',
'repeatEmail' => 'same:email',
'content' => 'required|length:10,5000',
]);
$validation->setFilters([
'fullName' => 'string'
'email' => 'email'
'content' => 'repeats|escape'
]);
$valid = $validation->validate($_POST);
if (!$valid) {
$messages = $validation->getMessages();
}
Sleet template engine
Sleet is lightweight and fast compiling PHP template engine written in C.
Built-in authentication:{% if this.auth.loggedIn() %}
// User is logged in, continue on
{{ this.auth.getUser().username }}
{% endif %}
{% if this.auth.loggedIn('admin') %}
// Admin privileges
{% else %}
// No access
{% endif %}
Easy translations: {{ this.i18n._('Hello :user', [':user' : username]) }}
{{ this.i18n._('Hello %s', [username]) }}
Use class in the view: {% use App\Models\Users %}
{% set user = Users::findOne(1) %}
{{ user.username }}
Debug variables: {{ dump('str', 1, 2.5, true, null, ['key': 'value']) }}
var 0 string (3) "str"
var 1 integer (1)
var 2 float (2.5)
var 3 boolean (true)
var 4 null
var 5 array (1) ( [key] => string (5) "value" )Control structures:
{% foreach users as key: user %}
{{ key ~ ": " ~ user.username }}
{% endforeach %}
{% for i=0; i<10; i++ %}
// Loop
{% endfor %}
{% while i<10 %}
// Loop
{% var i++ %}
{% endwhile %}
{% switch i %}
{% case 1 %}
// i equals 1
{% break %}
{% case 2 %}
// i equals 2
{% break %}
{% default %}
// Default case
{% break %}
{% endswitch %}