#4 new
Austin

Cannot Load Yaml (two cases)

Reported by Austin | January 16th, 2009 @ 09:14 PM

When running:

cake migrate g from db

Fatal error: Class 'Yaml' not found in ... line 404

FYI, that line number WILL be different because I threw in a quick "hack" fix; here's the full function _buildYaml:


function _buildYaml($tables)
{
    if (!is_array($tables)) $tables = array($tables);

    foreach ($tables as $table) {
        $dbShema['UP']['create_table'][$table] = $this->__buildUpSchema($table);
        $dbShema['DOWN']['drop_table'][] = $table;
    }

    if (count($dbShema['DOWN']['drop_table']) == 1) $dbShema['DOWN']['drop_table'] = $dbShema['DOWN']['drop_table'][0];

    // print file header
    $out  = '#'."\n";
    $out .= '# migration YAML file'."\n";
    $out .= '#'."\n";

    // Fix bug - can't load Yaml class
    require_once(dirname(__FILE__).DS.'..'.DS.'Yaml.php');
    return Yaml::Dump($dbShema);
}


You'll notice I just manually require_once'd the Yaml file. There's probably a better way to do this, and I'll leave that decision to you.

Same issue with: cake migrate

Fatal error: Class 'Yaml' not found in ... line 696

Again, I fixed it and that's why the line numbers are off slightly. I simply did the exact same require statement prior to Yaml::Load($yml);.

Please let me know if you need additional information as I'd be happy to help.

Comments and changes to this ticket

  • Dan Walker

    Dan Walker July 22nd, 2009 @ 04:11 PM

    You'll find there's an

       App::import('Vendor', 'Migrations.Yaml');
    

    add underneath it

       App::import('Vendor', 'Yaml',array('file' =>'Yaml.php'));
    

    The file is capitalised, and Cake's conventions are for it to not be. Of course, some filesystems this won't matter.

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

People watching this ticket

Pages