PHP code example of tuxboy / sdam

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

    

tuxboy / sdam example snippets


\SDAM\Config::current()->configure(
    [
        \SDAM\Config::DATABASE => [
            'dbname'   => 'database_name',
            'user'     => 'root',
            'password' => '',
            'host'     => 'localhost',
            'driver'   => 'pdo_mysql',
        ], // OR use .env for the database config
        \SDAM\Config::ENV_FILE        => 'path/your/.env'
        \SDAM\Config::ENTITY_PATH     => 'App\Entity\\',
        \SDAM\Config::AUTO_DROP_FIELD => false, // Optional (default value is true)
    ]
);

// Run migration engine in your app
$maintainer = new Maintainer([Entity::class]);
$maintainer->run();

// OR use middleware class
$maintainer = new \SDAM\Middleware\MaintainerMiddleware([\App\Entity\Post::class], $config);
$app->pipe($maintainer);

namespace App\Entity;

/**
 * Post
 *
 * @storeName custom_table_name
 */
class Post
{

    /**
     * @length 60
     * @var string
     */
    public $name;

    /**
     * @var string
     */
    public $slug;

    /**
     * @store false
     * @var string
     */
    public $tmp_property;

    /**
     * @text
     * @var string
     */
    public $content;
        
}