views:

32

answers:

1

I am using Doctrine 1.2 & ZF 1.10. I have my Doctrine CLI setup fine to do the default tasks. But I have created a couple classes I would like to be able to execute from the command line. How would I setup my application.ini or doctrine.php to register and use these new classes? For instance, I want to be able to execute APPLICATION_PATH . "/job/Migrate.php", which is just a class Migrate(), that has one public method run(), with something like

php.exe doctrine custom-migrate

Snippet of my application.ini

[production]
phpSettings.display_startup_errors = 0
phpSettings.display_errors = 0
includePaths.library = APPLICATION_PATH "/../lib"
bootstrap.path = APPLICATION_PATH "/Bootstrap.php"
bootstrap.class = "Bootstrap"
resources.frontController.controllerDirectory = APPLICATION_PATH "/modules/default/controllers"
resources.frontController.moduleDirectory = APPLICATION_PATH "/modules"
autoloaderNamespaces[] = "Doctrine"

; ---
; Database
; ---

doctrine.dsn = "mysql://user@pwd@localhost/db_name"
doctrine.data_fixtures_path = APPLICATION_PATH "/configs/data/fixtures"
doctrine.sql_path           = APPLICATION_PATH "/configs/data/sql"
doctrine.migrations_path    = APPLICATION_PATH "/configs/migrations"
doctrine.yaml_schema_path   = APPLICATION_PATH "/configs/schema.yml"
doctrine.models_path        = APPLICATION_PATH "/models" 

doctrine.generate_models_options.pearStyle = true
doctrine.generate_models_options.generateTableClasses = false
doctrine.generate_models_options.generateBaseClasses = true
doctrine.generate_models_options.baseClassPrefix = "Base_"
doctrine.generate_models_options.baseClassesDirectory = 
doctrine.generate_models_options.classPrefixFiles = false
doctrine.generate_models_options.classPrefix = "Model_"

Snippet of my doctrine.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($_SERVER['argv']);
+1  A: 

I'm afraid this is not possible via options of application.ini. The simplest solution here is to extend Doctrine_Cli which does the CLI job.

The simplest, doesn't mean the best.

Have you looked at beberlei's zf-doctrine at master - GitHub?

You may create custom Zend Tool provider then.

takeshin
I am actually watching this ZC which will probably do what I want. It's about using Zend_Tool in an application. http://www.zendcasts.com/integrating-zend_tool-into-your-application/2010/04/
Hallik