PHP code example of kerrialn / indoctrinate

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

    

kerrialn / indoctrinate example snippets




use Indoctrinate\Config\IndoctrinateConfig;

return static function (IndoctrinateConfig $config): void {
    $config->connection(
        driver: 'mysql',
        host: '127.0.0.1',
        port: 3306,
        dbname: 'your_database',
        user: 'your_user',
        password: 'your_password',
    );

    // Register individual rules, optionally with a constraint to configure them:
    $config->rules([
        EnsureAutoIncrementPrimaryKeyRule::class => new EnsureAutoIncrementPrimaryKeyRuleConstraints(
            skipTableLike: ['%session%', '%cache%', '%temp%', '%tmp%'],
        ),
    ]);

    // Or register a curated set of rules:
    // $config->sets([DoctrineCompatibilitySet::class]);
};

php bin/indoctrinate entities
php bin/indoctrinate entities --output=src/Entity --namespace="App\Entity"
php bin/indoctrinate entities --table=users --table=orders   # only these tables
php bin/indoctrinate entities --skip-table="%_log"           # skip tables matching pattern
php bin/indoctrinate entities --remove-naming-prefix=app     # "app_users" → "Users"
php bin/indoctrinate entities --annotations                  # force @ORM\ annotations
php bin/indoctrinate entities --attributes                   # force #[ORM\] attributes