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
    foreach ($GLOBALS as $helperSetCandidate) {
24
        if ($helperSetCandidate instanceof \Symfony\Component\Console\Helper\HelperSet) {
25
            $helperSet = $helperSetCandidate;
26 27 28 29 30
            break;
        }
    }
}

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

33
$cli = new \Symfony\Component\Console\Application('Doctrine Command Line Interface', Doctrine\DBAL\Version::VERSION);
34 35 36 37 38 39 40 41
$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(),

));
42
$cli->run();