PHP code example of ciikkeer / hx

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

    

ciikkeer / hx example snippets



ccess version information directly as a property
 *
 */
gf()->fun->debug->print_r(gf()->version->about())->die

/* testing ...
 *
 */
gf()->fun->debug->print_r (gf()->db->mysqli->open_with_env_json(__DIR__ . '/../../../env/env.json')->get_db_information())->die('ok');

/* test db no transcation
 *
 */
$db = gf()->db->mysqli->open_with_env_json(__DIR__ . '/../../../env/env.json');$db->connect()->query("select version(),now();")->go()->for_each ( function($k,$v)
{
	gf()->fun->debug->print_r ($k,$v);
});
		
/* The entire database stack initializes only when you access ->db
 *
 */ 
$result = $db->query('SELECT * FROM users WHERE id = ?')->ai(1)/* bind integer parameter */->go()/* execute */->for_each ( function($k, $v)
{
    echo $v->name;
});

gf()->route->add('/test/about' ,function (i_request $r,i_response $s) { return $s->success('test.ok');});

/* Replace the database service with a mock at runtime
 *
 */
gf()->ado_inject('db', new MyMockDatabase());

/* Simulate Redis injection using the new Redis library
 *
 */
 gf()->cache->ado_inject('redis', c_redis_mock_test_inject::class);

/* All subsequent code using gf()->db now uses your mock no container rebuild, no configuration changes needed
 *
 */

gf()->dc()->myTempValue = 'stored safely';