PHP code example of inxilpro / zit

1. Go to this page and download the library: Download inxilpro/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/ */

    

inxilpro / zit example snippets


$container = new \Zit\Container();
$container->set('auth', function() {
	return new Auth();
});

$container->set('auth', function($container) {
	return new Auth($container->get('db'));
});

$container->setAuth(function() { /* ... */ }); // Or:
$container->set_auth(function() { /* ... */ });

$container->get('auth');

$container->getAuth(); // Or:
$container->get_auth();

$container->fresh('auth'); // Or:
$container->freshAuth(); // Or:
$container->fresh_auth(); // Or:
$container->newAuth(); // Or:
$container->new_auth();

$container->setUser(function($c, $id)) {
	$user = new User($id);
	$user->setDb($c->getDb());
	return $user;
});

$user = $container->newUser(1);

// Parameters are taken into account when caching results:
$user2 = $container->getUser(1); // $user2 === $user;

$container->set('api_key', 'abcd1234567890');
$key = $container->get('api_key');

namespace MyApp\Di;

class Container extends \Zit\Container
{
	public function __construct()
	{
		$this->setAuth(function() { /* ... */ });
		$this->setUser(function() { /* ... */ });
	}
}