PHP code example of polaris / pdo

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

    

polaris / pdo example snippets


use Polaris\Pdo\PdoAdapter;

$pdo = new PDO('pgsql:host=localhost;dbname=app', $user, $password);
$adapter = new PdoAdapter($pdo);   // the dialect is detected from the driver

$polaris = Polaris::create(new Config(database: $adapter, /* ... */));

use Polaris\Authorization\PermissionCatalog;
use Polaris\Authorization\PermissionCatalogSeeder;
use Polaris\Contract\Dialect;
use Polaris\Pdo\SqlSchema;

foreach (SqlSchema::createAll(Dialect::Postgres) as $statement) {
    $adapter->exec($statement);
}
(new PermissionCatalogSeeder(new PermissionCatalog()))->seed($adapter, new DateTimeImmutable());

use Polaris\Pdo\SchemaInstaller;

$created = SchemaInstaller::createMissing($adapter, catalog: $polaris->graph()->permissionCatalog());