PHP code example of cathedral / builder

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

    

cathedral / builder example snippets


/**
 * Bootstrap
 *
 * If you don't have a bootstrap method this one will do.
 *
 * @param MvcEvent $e
 */
public function onBootstrap(\Laminas\Mvc\MvcEvent $e): void {
    // Add this line to register the static method
    \Laminas\Db\TableGateway\Feature\GlobalAdapterFeature::setStaticAdapter($e->getApplication()->getServiceManager()->get('Laminas\Db\Adapter\Adapter'));
}

    // Additional modules to Cathedral\Builder',
    ],


    return [
        'modules' => [
            // ...
            'Cathedral\Builder',
        ],
        // ...
    ];

    //Echo to screen
    echo $buildManager->getDataTableCode();
    echo $buildManager->getEntityAbstractCode();
    echo $buildManager->getEntityCode();

    //Write to file
    $buildManager->writeDataTable();
    $buildManager->writeEntityAbstract();
    $buildManager->writeEntity();

// Create Settings & User table objects
$settingaTable = new SettingsTable();
$usersTable = new UsersTable();

// Two simple select events to see it in action
$settingaTable->getEventManager()->attach('postSelect', function(TableGatewayEvent $event) {
    Logger::dump($event->getParam('result')->current(), 'TableGatewayEvent::Setting', false);
});

$usersTable->getEventManager()->attach('postSelect', function(TableGatewayEvent $event) {
    Logger::dump($event->getParam('result')->current(), 'TableGatewayEvent::User', false);
});

// More useful, if a user is added we can run some init setup tasks
$usersTable->getEventManager()->attach('postInsert', function (TableGatewayEvent $event) {
    /** @var ResultInterface $result */
    $result = $event->getParam('result');
    $generatedId = $result->getGeneratedValue();

    // do something with the generated identifier...
});

// More useful, if a setting is updated rebuild cache or ...
$settingaTable->getEventManager()->attach('postUpdate', function (TableGatewayEvent $event) {
    /** @var ResultInterface $result */
    $result = $event->getParam('result');
    $generatedId = $result->getGeneratedValue();

    // do something with the generated identifier...
});

$user = $usersTable->getUser(1);
$pagination = $settingaTable->getSetting('pagination');
$dbVersion = (new Setting())->get('dbVersion');

    $ php composer.phar update