Beispiel #1
0
    public function commandLine()
    {
        $config = array('
				 data_fixtures_path' => APPPATH . '/fixtures', 'models_path' => APPPATH . '/models', 'migrations_path' => APPPATH . '/migrations', 'sql_path' => APPPATH . '/sql', 'yaml_schema_path' => APPPATH . '/schema');
        $cli = new Doctrine_Cli($config);
        $cli->run($_SERVER['argv']);
    }
 public function index()
 {
     //Only accessible through CLI
     if (PHP_SAPI !== 'cli') {
         Kohana::show_404();
     }
     //Clear the output buffer in preperation for any user prompts
     ob_end_flush();
     //Default configuration settings
     $config = array('data_fixtures_path' => MODPATH . 'doctrine' . DIRECTORY_SEPARATOR . 'fixtures' . DIRECTORY_SEPARATOR, 'models_path' => MODPATH . 'doctrine' . DIRECTORY_SEPARATOR . 'models' . DIRECTORY_SEPARATOR, 'migrations_path' => MODPATH . 'doctrine' . DIRECTORY_SEPARATOR . 'migrations' . DIRECTORY_SEPARATOR, 'sql_path' => MODPATH . 'doctrine' . DIRECTORY_SEPARATOR . 'schema' . DIRECTORY_SEPARATOR, 'yaml_schema_path' => MODPATH . 'doctrine' . DIRECTORY_SEPARATOR . 'schema' . DIRECTORY_SEPARATOR, 'generateTableClasses' => true);
     $cli = new Doctrine_Cli($config);
     //remove our routing path
     $args = $_SERVER['argv'];
     $call = array_shift($args);
     $route = array_shift($args);
     array_unshift($args, $call);
     $cli->run($args);
 }
 public function create(Skt_Core_Request $req)
 {
     try {
         ob_start();
         // inserindo a biblioteca doctrine
         $dir = $this->_dir_app . $this->_configure->path_doctrine_library;
         if (!is_dir($dir)) {
             Skt_Core_Prompt::print_($dir, Skt_Core_Prompt::ERROR);
             $this->copy_directory('_makers/doct/tpls/Doctrine-1.2.4/', $dir);
             $this->_file->include_tpl("inc_doctrine", $this->_dir_app . '_extensions');
         }
         // criando diretorios para o doctrine models, base, schemas
         foreach ($this->_configure->doctrine_configure as $directory) {
             $this->_directory->create($this->_dir_app . $directory);
         }
         // configurando o nome das pastas para o gerador de codigos
         $confs = array();
         foreach ($this->_configure->doctrine_configure as $conf_name => $conf_value) {
             $confs[$conf_name] = $this->_dir_app . $conf_value;
         }
         // conectando o doctrine ao banco de dados atraves do dns em configuracao.php
         require_once $this->_dir_app . '_maps/doctrine/Doctrine.php';
         spl_autoload_register(array('Doctrine', 'autoload'));
         if (!Doctrine_Manager::connection($this->_configure->doctrine_database_dns)) {
             throw new Exception('Not possible connect in database');
         }
         // executando os comandos doctrine
         $cli = new Doctrine_Cli($confs);
         $params = array_merge(array('doctrine'), explode('.', $req->getParam('command')));
         $cli->run($params);
         // capturando saida do doctrine para enviar como json
         $out = ob_get_contents();
         ob_end_clean();
         // inserindo a saida no json
         if (isset($out) && !empty($out)) {
             Skt_Core_Prompt::print_($out, Skt_Core_Prompt::ALERT);
         }
     } catch (Exception $e) {
         Skt_Core_Prompt::print_($e->getMessage(), Skt_Core_Prompt::ERROR);
     }
 }
<?php

/**
 * Doctrine CLI script
 *
 * @author Juozas Kaziukenas (juozas@juokaz.com)
 */
define('APPLICATION_ENV', 'development');
define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../application'));
set_include_path(implode(PATH_SEPARATOR, array(realpath(APPLICATION_PATH . '/../library'), './', get_include_path())));
require_once 'Zend/Application.php';
// Create application, bootstrap, and run
$application = new Zend_Application(APPLICATION_ENV, APPLICATION_PATH . '/configs/application.ini');
$application->getBootstrap()->bootstrap('doctrine');
// set aggressive loading to make sure migrations are working
Doctrine_Manager::getInstance()->setAttribute(Doctrine::ATTR_MODEL_LOADING, Doctrine_Core::MODEL_LOADING_AGGRESSIVE);
$options = $application->getBootstrap()->getOptions();
$cli = new Doctrine_Cli($options['doctrine']);
$cli->run($_SERVER['argv']);
Beispiel #5
0
<?php

error_reporting(E_ALL | E_STRICT);
// Define path to application directory
defined('APPLICATION_PATH') || define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../../application'));
// Define application environment
defined('APPLICATION_ENV') || define('APPLICATION_ENV', getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'testing');
// Ensure library/ is on include_path
set_include_path(implode(PATH_SEPARATOR, array(realpath(APPLICATION_PATH . '/../library'), get_include_path())));
/** Zend_Application */
require_once 'Zend/Application.php';
require_once 'Zend/Config.php';
require_once 'Zend/Config/Ini.php';
require_once 'ControllerTestCase.php';
$application = new Zend_Application(APPLICATION_ENV, APPLICATION_PATH . '/configs/application.ini');
$application->getBootstrap()->bootstrap("doctrine");
$cli = new Doctrine_Cli($application->getOption('doctrine'));
@$cli->run(array("doctrine", "drop-db", "force"));
@$cli->run(array("doctrine", "generate-models-yaml", "force"));
@$cli->run(array("doctrine", "create-db", "force"));
@$cli->run(array("doctrine", "create-tables", "force"));
$cli->run(array("doctrine", "load-data", "force"));
Beispiel #6
0
 *  ./doctrine original-doctrine-command -module path-to-your-module
 */
// Module name argument
$moduleNameIndex = array_search('-module', $argv);
if ($moduleNameIndex !== false) {
    // Module argument is set
    // Check & Access Module Name
    $moduleName = isset($argv[$moduleNameIndex + 1]) ? $argv[$moduleNameIndex + 1] : null;
    if (!empty($moduleName)) {
        // Module name is not empty and already exist
        if (!is_dir(MODULES_PATH . "/" . $moduleName)) {
            die("** Module path not found! **" . PHP_EOL);
        }
        // Fiter SeperatorToCamelCase Setup
        $filter = new Zend_Filter_Word_UnderscoreToCamelCase();
        $camelCaseModuleName = $filter->setSeparator('-')->filter($moduleName);
        // Replacement Mapping, String Replace and Apply Filter
        $mapping = array('find' => array(APPLICATION_PATH, DEVELOPER_PATH, "Model_"), 'replace' => array(MODULES_PATH . "/" . $moduleName, MODULES_PATH . "/" . $moduleName . "/" . $paths['dev'], $camelCaseModuleName . "_Model_"));
        // Apply New Cli Settings
        $doctrineCliCfgs = str_replace($mapping['find'], $mapping['replace'], array_merge($doctrineCliCfgs, array('generate_models_options' => str_replace($mapping['find'], $mapping['replace'], $doctrineCliCfgs['generate_models_options']))));
        echo "** '" . $moduleName . "' module is being processed... **" . PHP_EOL;
    } else {
        //KBBTODO: Add console code color
        die("** Please type your module path! **" . PHP_EOL . "~\$>./doctrine original-doctrine-command -module path-to-your-module" . PHP_EOL);
    }
}
// -----------------------------------------------------------------------------
// Cli Initialize
$cli = new Doctrine_Cli($doctrineCliCfgs);
$cli->run($argv);
// -----------------------------------------------------------------------------
Beispiel #7
0
<?php

require "public/header.php";
$application->bootstrap();
$defaultPath = APPLICATION_PATH;
$args = $_SERVER["argv"];
//Perhaps, I want to create models and tables or create sqls for just a module!!!
//Usage: ./doctrine -m MODULE_NAME generate-models-yaml
//The above usage will only generate models for the yaml defined in the module directory
$moduleNameIndex = array_search("-m", $args);
if ($moduleNameIndex !== false) {
    //Check if the module bootstrapping exists or not...
    $defaultPath = APPLICATION_PATH . "/modules/" . $args[$moduleNameIndex + 1];
    //Now unset these module variables to prevent causing problems in the doctrine command line
    array_splice($args, $moduleNameIndex, 2);
}
// Configure Doctrine Cli
// Normally these are arguments to the cli tasks but if they are set here the arguments will be auto-filled
$config = array('data_fixtures_path' => $defaultPath . '/data/fixtures', 'models_path' => $defaultPath . '/models/doctrine/', 'migrations_path' => $defaultPath . '/data/migrations', 'sql_path' => $defaultPath . '/data/sql', 'yaml_schema_path' => $defaultPath . '/data/schema', "generate_models_options" => array("phpDocPackage" => "Kartaca", "phpDocSubpackage" => "Doctrine", "baseClassName" => "Kartaca_Model_Doctrine_Record", "phpDocName" => "Roy Simkes", "phpDocEmail" => "*****@*****.**"));
$cli = new Doctrine_Cli($config);
$cli->run($args);
<?php

/**
 * Script to test the output from Doctrine_Cli
 * 
 * @author Dan Bettles <*****@*****.**>
 */
require_once dirname(dirname(dirname(__FILE__))) . '/lib/Doctrine.php';
spl_autoload_register(array('Doctrine', 'autoload'));
$cli = new Doctrine_Cli();
require_once dirname(__FILE__) . '/TestTask02.php';
//Either...:
$cli->registerTaskClass('Doctrine_Cli_TestCase_TestTask02');
//...Or:
$cli->registerIncludedTaskClasses();
$cli->run($_SERVER['argv']);
 public function notify($notification = null, $style = null)
 {
     parent::notify($notification, $style);
 }
Beispiel #10
0
<?php

/**
 * Doctrine CLI script
 *
 * @author Juozas Kaziukenas (juozas@juokaz.com)
 */
define('APPLICATION_ENV', 'development');
define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../application'));
set_include_path(implode(PATH_SEPARATOR, array(realpath(APPLICATION_PATH . '/../library'), get_include_path())));
require_once 'Zend/Application.php';
// Create application, bootstrap, and run
$application = new Zend_Application(APPLICATION_ENV, APPLICATION_PATH . '/configs/application.ini');
$application->getBootstrap()->bootstrap('doctrine');
$options = $application->getBootstrap()->getOptions();
$cli = new Doctrine_Cli($options['resources']['doctrine']);
// Load tasks from custom location
$tasks = './Doctrine/Task';
if (file_exists($tasks)) {
    $cli->loadTasks($tasks);
}
$cli->run($_SERVER['argv']);
 public function create($task)
 {
     $this->_setUp();
     $this->_cli->run(array(0 => "doctrine", 1 => $task));
 }
Beispiel #12
0
<?php

// Define path to application directory
defined('APPLICATION_PATH') || define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../../application'));
// Define application environment
define('APPLICATION_ENV', 'testing');
// Ensure library/ is on include_path
set_include_path(implode(PATH_SEPARATOR, array(realpath(APPLICATION_PATH . '/../library'), get_include_path())));
/** Zend_Application */
require_once 'Zend/Application.php';
// Create application, bootstrap, and run
$application = new Zend_Application(APPLICATION_ENV, APPLICATION_PATH . '/configs/application.ini');
$application->getBootstrap()->bootstrap('doctrine');
$config = $application->getOption('doctrine');
$cli = new Doctrine_Cli($config);
@$cli->run(array("doctrine", "build-all-reload", "force"));
Beispiel #13
0
	/**
	 * Set up migration object
	 */
	protected function setUpMigration(Doctrine_Cli $cli) {
		$config = $cli->getConfig();
		$this->migration = new Doctrine_Migration($config['migrations_path']);
	}