I'm trying to generate DAO and SQL files, when I run "php ./GenCode.php" in my xml path, I get this error in my console.

$ php ./GenCode.php

civicrm_domain.version := 5.1.alpha1

Parsing schema description schema/Schema.xml
Extracting database information
Extracting table information

Fatal error: Uncaught exception 'Exception' with message 'Failed to locate template for civicrm.config.php' in 

Stack trace:

#0 C:\wamp64\www\drupal\modules\civicrm\CRM\Core\CodeGen\Config.php(10): CRM_Core_CodeGen_Config->setupCms()
#1 C:\wamp64\www\drupal\modules\civicrm\CRM\Core\CodeGen\Main.php(115): CRM_Core_CodeGen_Config->run()
#2 C:\wamp64\www\drupal\modules\civicrm\CRM\Core\CodeGen\Main.php(100): CRM_Core_CodeGen_Main->runAllTasks()
#3 C:\wamp64\www\drupal\modules\civicrm\extern\membership\xml\GenCode.php(39): CRM_Core_CodeGen_Main->main()
#4 {main}

thrown in C:\wamp64\www\drupal\modules\civicrm\CRM\Core\CodeGen\Config.php on line 35

when I look to the config.php file, it seems correct

elseif ($this->config->cms !== 'joomla') {
  $configTemplate = $this->findConfigTemplate($this->config->cms);
  if ($configTemplate) {
    echo "Generating civicrm.config.php\n";
    copy($configTemplate, '../civicrm.config.php');
  else {
    throw new Exception("Failed to locate template for civicrm.config.php");

but it gives the same error, can you help me please? Thanks Fidi


I had this same problem today. While this may be too late for you, what I found was that somehow, the git repo in <webroot>/sites/all/modules/civicrm/drupal was set to the master branch and not the 7.x-master branch. Once I checked out 7.x-master and did a git pull my problem resolved.

  • I totally forgot about this, but finding it saved my butt today. Sorry I can't give you an upvote, 2019 Jon. – Jon G - Megaphone Tech Aug 30 '20 at 3:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.