doctrine.php 1.21 KB
Newer Older
1 2
<?php

3
require_once 'Doctrine/Common/ClassLoader.php';
4

5
$classLoader = new \Doctrine\Common\ClassLoader('Doctrine');
6 7
$classLoader->register();

8
$classLoader = new \Doctrine\Common\ClassLoader('Symfony', 'Doctrine');
9
$classLoader->register();
10

11
$configFile = getcwd() . DIRECTORY_SEPARATOR . 'cli-config.php';
12

13
$helperSet = null;
14 15 16 17 18 19 20 21 22
if (file_exists($configFile)) {
    if ( ! is_readable($configFile)) {
        trigger_error(
            'Configuration file [' . $configFile . '] does not have read permission.', E_ERROR
        );
    }

    require $configFile;
    
23 24 25
    foreach ($GLOBALS as $helperSetCandidate) {
        if ($helperSetCandidate instanceof \Symfony\Components\Console\Helper\HelperSet) {
            $helperSet = $helperSetCandidate;
26 27 28 29 30
            break;
        }
    }
}

31 32
$helperSet = ($helperSet) ?: new \Symfony\Components\Console\Helper\HelperSet();

33
$cli = new \Symfony\Components\Console\Application('Doctrine Command Line Interface', Doctrine\DBAL\Version::VERSION);
34 35 36 37 38 39 40 41 42
$cli->setCatchExceptions(true);
$cli->setHelperSet($helperSet);
$cli->addCommands(array(
    // DBAL Commands
    new \Doctrine\DBAL\Tools\Console\Command\RunSqlCommand(),
    new \Doctrine\DBAL\Tools\Console\Command\ImportCommand(),

));
$cli->run();