Doctrine 1
  1. Doctrine 1
  2. DC-753

doctrine generate-migrations-diff throws "No php or yml files found at path"

    Details

    • Type: Bug Bug
    • Status: Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: 1.2.2
    • Fix Version/s: 1.2.2
    • Component/s: Migrations
    • Labels:
      None
    • Environment:
      WIndows 7 x64, WAMP, PHP 5.2.11 & 5.3

      Description

      I am trying to generate migrations from the CLI but I get the error mentioned in the title. I did some searching and this seems to have been a known problem and was fixed, however, I'm getting it and the path is correct, and there is even a schema.yml file I just generated, also through CLI.

      Here is the error:

      D:\wamp\www\project\src\administrator\components\com_project\doctrine>php doctrine generate-migrations-diff
      No php or yml files found at path: "D:\wamp\www\project\src\administrator\components\com_project\doctrine\schema"

      And here is what I have in my CLI file:

      require_once('../../../../libraries/doctrine/lib/Doctrine.php');

      spl_autoload_register(array('Doctrine','autoload'));

      Doctrine_Manager::connection('mysql://root@localhost/project','default');

      //Doctrine_Manager::getInstance()->setAttribute(Doctrine::ATTR_TBLNAME_FORMAT, 'jos_project_%s');
      Doctrine_Manager::getInstance()->setAttribute(Doctrine::ATTR_VALIDATE, Doctrine::VALIDATE_ALL);
      Doctrine_Manager::getInstance()->setAttribute(Doctrine::ATTR_QUOTE_IDENTIFIER, true);
      Doctrine::loadModels('models/generated');
      Doctrine::loadModels('models');

      $cli = new Doctrine_Cli(array(
      'data_fixtures_path' => dirname(_FILE_).DIRECTORY_SEPARATOR.'fixtures',
      'models_path' => dirname(_FILE_).DIRECTORY_SEPARATOR.'models',
      'migrations_path' => dirname(_FILE_).DIRECTORY_SEPARATOR.'migrations',
      'sql_path' => dirname(_FILE_).DIRECTORY_SEPARATOR.'sql',
      'yaml_schema_path' => dirname(_FILE_).DIRECTORY_SEPARATOR.'schema'
      ));

      $cli->run($_SERVER['argv']);

      I find this very weird because earlier today I was able to make a migration the same way but with Symfony's CLI, however, that is another project.

      Regards,

      David

        Activity

        Hide
        Marcelo Saldanha added a comment -

        I have the same problem, using symfony 1.4 latest sources. After reading about 20 (long) pages about similar issues, I've come up with a solution.

        The problem appears when the project still don't have any Models defined. Im my case, they were all new projects in the plugin activation stage. Curiously, the behaviour were random, as in some projects I could activate my Contacts plugin (the first), and in others I couldn't.

        After much consideration, the problem was that the var $extension in /doctrine/Doctrine/Migration/Diff.php was empty, and that was because the algorithm only considered the first entry of the directory. If it was a file, its extension was used. If not, the algorithm descended until it found a file as the first entry. BUT it never considered second (and following) entries, so as my first entry was the 'base' directory, and it was empty, no extension was ever found. This probably will not happen if the project have some models defined.

        And so, I came up with a solution. In doctrine/Doctrine/Migration/Diff.php, enclose this code in the _getItemExtension method (near line 350, in my copy) with a loop, such as:
        $idx = 0;
        while (strlen($extension) == 0) {
        if (isset($files[$idx])) {
        if (is_dir($files[$idx]))

        { $extension = $this->_getItemExtension($files[$idx]); }

        else

        { $pathInfo = pathinfo($files[$idx]); $extension = $pathInfo['extension']; }

        $idx++;
        }
        else break; // no more entries to seek
        }

        Now it keep looking in every folder until it finds a file WITH an extension, and stops when all the tree is searched.

        Hope that helps someone.

        best regards.

        Show
        Marcelo Saldanha added a comment - I have the same problem, using symfony 1.4 latest sources. After reading about 20 (long) pages about similar issues, I've come up with a solution. The problem appears when the project still don't have any Models defined. Im my case, they were all new projects in the plugin activation stage. Curiously, the behaviour were random, as in some projects I could activate my Contacts plugin (the first), and in others I couldn't. After much consideration, the problem was that the var $extension in /doctrine/Doctrine/Migration/Diff.php was empty, and that was because the algorithm only considered the first entry of the directory. If it was a file, its extension was used. If not, the algorithm descended until it found a file as the first entry. BUT it never considered second (and following) entries, so as my first entry was the 'base' directory, and it was empty, no extension was ever found. This probably will not happen if the project have some models defined. And so, I came up with a solution. In doctrine/Doctrine/Migration/Diff.php, enclose this code in the _getItemExtension method (near line 350, in my copy) with a loop, such as: $idx = 0; while (strlen($extension) == 0) { if (isset($files [$idx] )) { if (is_dir($files [$idx] )) { $extension = $this->_getItemExtension($files[$idx]); } else { $pathInfo = pathinfo($files[$idx]); $extension = $pathInfo['extension']; } $idx++; } else break; // no more entries to seek } Now it keep looking in every folder until it finds a file WITH an extension, and stops when all the tree is searched. Hope that helps someone. best regards.

          People

          • Assignee:
            Jonathan H. Wage
            Reporter:
            David Vega
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated: