beberlei / zf-doctrine

A Zend Framework 1.x and Doctrine 1.2 Integration - UNMAINTAINED
101 stars 21 forks source link

"zf generate-sql doctrine" successfully generates sql file, but this file is empty #6

Open HongKilDong opened 14 years ago

HongKilDong commented 14 years ago

I used forum.yml from readme for testing - model was generated successfully, but when I issued "zf generate-sql doctrine" it returns:

[Doctrine] Successfully written SQL for the current schema to disc. [Doctrine] Destination File: D:\work\zd/application/configs/sql\schema_20100618_142043.sql

but generated file named "schema_20100618_142043.sql" was empty

nunthrey commented 14 years ago

try 'zf show doctrine'. How many models it'll show?

HongKilDong commented 14 years ago

'zf show doctrine' returns:

[Doctrine] Current Doctrine Model Directories: [Doctrine] * Module default: D:\work\zd/application/\models\

[Doctrine] All current models:

[Doctrine] The current migration version is: 0

In spite of the fact I have successfully generated model files in 'D:\work\zd\application\models'

nunthrey commented 14 years ago

I guess, you forgot to initialize module auotoloaders in bootstrap like this:

class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{
    public function _initModuleLoaders()
    {
        $this->bootstrap('Frontcontroller');

        $fc = $this->getResource('Frontcontroller');
        $modules = $fc->getControllerDirectory();

        foreach ($modules AS $module => $dir) {
            $moduleName = strtolower($module);
            $moduleName = str_replace(array('-', '.'), ' ', $moduleName);
            $moduleName = ucwords($moduleName);
            $moduleName = str_replace(' ', '', $moduleName);

            $loader = new Zend_Application_Module_Autoloader(array(
                'namespace' => $moduleName,
                'basePath' => realpath($dir . "/../"),
            ));
        }
    }
}
HongKilDong commented 14 years ago

I haven't used modules - I've just changed all "Forum" prefixes to "Default" in model entities' names in my .yml schema file - so I think I don't need module autoloaders - my model files have been generated in default application model's directory.

Moreover I'am sure it successfully locates model files as I can see it with FileMon utility.

By the way - is there a way to debug cli php - because it reports no error-warnings neither to apache's error log nor stdout? Where are cli php settings located?

paramah commented 14 years ago

i have the same problem

MarcoAlting commented 14 years ago

I also have the same problem. And I'm using a modular setup. But I also get an error when trying to build my project:

[Doctrine] No sql queries found to create tables from. [Doctrine] Have you generated a model from your YAML schema?

My module/model directory contain generated model classes from th YAML schema.

taat commented 14 years ago

I also had the same problem.

I'm not using Benjamin's generic module loader, so the needed classes were generated, but not loaded automatically by autoloader.

The solution is, that I forgot to create Boostrap.php for this specific module.

pesec commented 13 years ago

I have the same problem, when trying build project, generate sql or create tables. Models genereate, but nothing is done with database(. Jon Lebensold speaks in http://www.zendcasts.com/deep-integration-between-zend-and-doctrine-1-2/2010/01/ that model_loading_Aggressive helps with model_loading in docrinte1.2.x but that's not the case

mfuller commented 13 years ago

Hi I'm using the Single Library Path and I too have the same problem when trying to generate sql or create tables. I even added the public function _initModuleLoaders() method in my bootstrap just in case. Although I don't think I need to according to the documentation.

Using the model_loading_zend it works fine.

Thanks.

adamkopec commented 12 years ago

I've had a similar issue to @HongKilDong & followers. In order to fix it I've had to delete a folder that accidentally appeared in the models/ directory. Apparently this tool doesn't accept anything other than models and Base/ directory in the models folder.