I have about 22 DB tables for my extension and more are coming in as I work on the extension, I need to be able to automatically generate the DAO and BAO files to access these tables from my code, I followed this thread How do I add a new table to my extension? and it seems to be worked for the author of the post but I need more light on how generate the xml schema files if they can be generated and where do I run the xml/phpGencode.php specified in the comment to get the DAO files.

2 Answers 2


Installing civix and generating Extension using civix is the correct way you can find more details in the below link http://wiki.civicrm.org/confluence/display/CRMDOC/Create+a+Module+Extension


For shortcut create an hook_civicrm_install and use the statement $sql = "CREATE TABLE "; $dao = CRM_Core_DAO::executeQuery( $sql );

The above code will do the trick - but always try to use the first method using civix

  • civix generate:entity sounds like what the OP is looking for, but this carries a warning of being experimental and incomplete.
    – DaveFF
    Jul 14, 2015 at 13:31
  • civix:generate entity should do that if i am to use civix for this but i get this [ErrorException] Warning: ini_set(): A session is active. You cannot change the session modu le's ini settings at this time in /home/ayprograms/civicrm/buildkit/extern/ civix/vendor/symfony/symfony/src/Symfony/Component/HttpFoundation/Session/S torage/Handler/NativeFileSessionHandler.php line 56 Jul 14, 2015 at 13:34
  • it seems like you have some PHP error please try the below link stackoverflow.com/questions/11384416/… this might help you Jul 14, 2015 at 13:58

You could possibly rewrite the question. "How do I define a new Entity type in my extension?"

If that is the question you are asking, then the most up to date reference for adding an entity to an extension can be found here: https://docs.civicrm.org/dev/en/master/extensions/civix/#add-a-new-entity

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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