1. Go to this page and download the library: Download dlid/cdbyuml 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/ */
dlid / cdbyuml example snippets
$cdbyuml->setOptions([
'proxy' => null, // Proxy address
'proxyauth' => null, // Proxy authentication (username:password)
'query' => null, // \PDO Object or custom function to fetch data from database
'sql_dialect' => 'sqlite', // sqlite or mysql. Determines which queries to run
'style' => 'plain', // Yuml.me styles (plain, scruffy or nofunky)
'scale' => 100, // Yuml.me scale (100 = 100%)
'close' => null, // Optional callback function to close database
'force' => false, // Ignore all caching.
'cachepath' => null, // Full path to the cachefile
'cachetime' => '15 minutes' // Maximum time before re-validating database structure
]);
// Open a database connection
$dbh = new PDO('sqlite:mydatabase.sqlite3');
// Initialize CDBYuml
$cdbyuml = new \Dlid\DbYuml\CDbYuml();
$cdbyuml->setOptions([
'sql_dialect' => 'sqlite',
// Callback function query the database for metadata
'query' => function($query, $parameters) use ($dbh) {
// Pass along query and parameters to our open PDO connection
$stmt = $dbh->prepare($query);
$stmt->execute($parameters);
return $stmt->fetchAll(\PDO::FETCH_ASSOC);
}
]);
// Fetch metadata from database and generate the YUml string
$cdbyuml->execute()
#->outputText() // Uncomment to see debug information
// Output the generated diagram
->outputImage();
# Just the PDO:
$cdbyuml->setOptions($dbh);
# Some additional options
$cdbyuml->setOptions($dbh, [ 'proxy' => 'http://some-proxy.example.net:8080' ]);
# Example passing just the PDO:
$cdbyuml = new \Dlid\DbYuml\CDbYuml([
'query' => $dbh,
'cachepath' => '/users/david/temp/cache/dbcache1'
]);