Answers.Body: <p>You put it in your own extension, under the CRM folder and subfolders you need to create depending on the class name. See <a href="https://docs.civicrm.org/civirules/en/latest/create-your-own-action/#step-2-add-a-class-that-extends-crm_civirule_action" rel="nofollow noreferrer">https://docs.civicrm.org/civirules/en/latest/create-your-own-action/#step-2-add-a-class-that-extends-crm_civirule_action</a></p>
  
  <pre><code>You can include the class file in the Civirules extension if you want,
  but you can also include it in your own extension. This class should extend
  CRM_Civirules_Action to be able to add your action to the CiviRules Engine
  </code></pre>
  
  <p>So let's say your class is CRM_Mynamespace_CivirulesActions_Contact_Subtype, then you'd call the file Subtype.php and put it in your extension in CRM/Mynamespace/CivirulesActions/Contact</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-01-18T08:55:57.320Z
Answers.Text: Thank you for the reply. This is the first time I have seen it documented that the Class name is anything other than a random collection of joined words. I suppose it is sort of obvious when you are told but how was I to know? Maybe the text you highlight above should also say "and the class name determines the path to the file containing the new class". I have accepted your answer. Thank you
Answers.UserDisplayName: Crofter
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-01-18T18:23:26.330Z
Answers.Text: Up to a point the class name is a random collection of joined words. The file path is a standard PHP PSR-4 autoloader rule. The CRM_Mynamespace part is a little specific to where civi extensions look for files and the convention that civix uses, but otherwise the part after it can be whatever you want. You could do `CRM_Mynamespace_Grapple_Grommit_Foo extends CRM_Civirules_Action` and put the Foo.php file in CRM/Mynamespace/Grapple/Grommit. Often you would do `civix generate:XXX`, and then it makes the files for you, there just isn't an XXX command for CiviRules, but it's the same pattern.
Answers.UserDisplayName: Demerit
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-01-18T00:36:38.663Z
Answers.LastActivityDate: 2020-01-18T00:36:38.663Z
Answers.UserDisplayName: Demerit
Body: <p>I have written a new CiviRules Action and added the entry to the database but I don't know where to put the php file. I have read all the documents I can find but I can't find any information about a directory structure for rules addons. I would like to keep it as part of an extension I have written. Any help with the file location would be appreciated.</p>
  
  <p>Thanks</p>
  
Tags: <civirules>
Title: File location for new CiviRules Action
ThreadText: # File location for new CiviRules Action
  
  (Asked by: username_0 on 2020-01-17)
  
  I have written a new CiviRules Action and added the entry to the database but I don't know where to put the php file. I have read all the documents I can find but I can't find any information about a directory structure for rules addons. I would like to keep it as part of an extension I have written. Any help with the file location would be appreciated.
  
  Thanks
  
  **Tags:** civirules
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2020-01-18. Score: 2 | Accepted answer
  
  You put it in your own extension, under the CRM folder and subfolders you need to create depending on the class name. See <https://docs.civicrm.org/civirules/en/latest/create-your-own-action/#step-2-add-a-class-that-extends-crm_civirule_action>
  
  ```
  You can include the class file in the Civirules extension if you want,
  but you can also include it in your own extension. This class should extend
  CRM_Civirules_Action to be able to add your action to the CiviRules Engine
  
  ```
  
  So let's say your class is CRM\_Mynamespace\_CivirulesActions\_Contact\_Subtype, then you'd call the file Subtype.php and put it in your extension in CRM/Mynamespace/CivirulesActions/Contact
  
  > **Comments:**
  > **username_0**: Thank you for the reply. This is the first time I have seen it documented that the Class name is anything other than a random collection of joined words. I suppose it is sort of obvious when you are told but how was I to know? Maybe the text you highlight above should also say "and the class name determines the path to the file containing the new class". I have accepted your answer. Thank you  
  > **username_1**: Up to a point the class name is a random collection of joined words. The file path is a standard PHP PSR-4 autoloader rule. The CRM_Mynamespace part is a little specific to where civi extensions look for files and the convention that civix uses, but otherwise the part after it can be whatever you want. You could do `CRM_Mynamespace_Grapple_Grommit_Foo extends CRM_Civirules_Action` and put the Foo.php file in CRM/Mynamespace/Grapple/Grommit. Often you would do `civix generate:XXX`, and then it makes the files for you, there just isn't an XXX command for CiviRules, but it's the same pattern.  
  
  ---
  
  