1. Go to this page and download the library: Download selvinortiz/zit 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/ */
selvinortiz / zit example snippets
// Make an instance
$app = Zit::make();
// Stash a config object
$app->stash('config', new Config(['usr' => 'root', 'pwd' => 'secret']));
// Bind a session generator
$app->bind('session', function() {
return new Session();
});
// Bind a database generator
$app->bind('db', function($app) {
return new Db($app->config->usr, $app->config->pwd);
});
// Extend your $app with new functionality
$app->extend('end', function($app) {
$app->db->close();
$app->session->destroy();
});
// Finish
$app->end();
// Stash a config object
Zit::stash('config', new Config(['usr' => 'root', 'pwd' => 'secret']));
// Bind a session generator
Zit::bind('session', function() {
return new Session();
});
// Bind a database generator
Zit::bind('db', function($zit) {
return new Db($zit->config->usr, $zit->config->pwd);
});
// Extend Zit with new functionality
Zit::extend('end', function($zit) {
$zit->db->close();
$zit->session->destroy();
});
// Finish
Zit::end();
Zit::pop('db'); // Formal
Zit::db(); // Via __callStatic()
Zit::db // Via __callStatic() property sniffing
// If you had done $app = Zit::make()
$app->pop('db'); // Formal
$app->db(); // Via __call()
$app->db; // Via __get()
Zit::pop('db');
// See the note above on popping stuff out
Zit::make()->bind('db', function($zit) {
return new Db($zit->config->usr, $zit->config->pwd);
});