PHP code example of phpnomad / mysql-integration

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

    

phpnomad / mysql-integration example snippets




use PHPNomad\Di\Container\Container;
use PHPNomad\Loader\Bootstrapper;
use PHPNomad\MySql\Integration\Interfaces\DatabaseStrategy;
use PHPNomad\MySql\Integration\MySqlInitializer;
use PHPNomad\SafeMySql\Integration\Strategies\SafeMySqlDatabaseStrategy;
use SafeMySQL;

$container = new Container();

$container->bindFactory(
    DatabaseStrategy::class,
    fn() => new SafeMySqlDatabaseStrategy(new SafeMySQL([
        'host' => '127.0.0.1',
        'user' => 'myapp',
        'pass' => 'secret',
        'db'   => 'myapp',
    ]))
);

$bootstrapper = new Bootstrapper(
    $container,
    new MySqlInitializer()
);

$bootstrapper->load();