PHP code example of qumuinc / ulidtypes

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

    

qumuinc / ulidtypes example snippets


...
Plugin::load('qumuinc/UlidTypes', ['bootstrap' => true]);
...

...
use Cake\Database\Schema\TableSchemaInterface;
...
class XXXXXXXXTable extends Table
{
    protected function _initializeSchema(TableSchemaInterface $table): TableSchemaInterface
    {
        parent::_initializeSchema($table);
        $table->setColumnType('id', 'ulid'); // set ulid type for id

        return $table;
    }
}
...

...
use PrefixUlidType\PrefixUlidTypeTrait;
...
class XXXXXXXXTable extends Table
{
    use PrefixUlidTypeTrait;
}
...

...
use Cake\Database\Schema\TableSchemaInterface;
use PrefixUlidType\PrefixUlidTypeTrait;
...
class XXXXXXXXTable extends Table
{
    use PrefixUlidTypeTrait;

    protected function _initializeSchema(TableSchemaInterface $table): TableSchemaInterface
    {
        parent::_traitInitSchema($table);
        $table->setColumnType('code', 'char'); // set any type for property

        return $table;
    }
}
...