Title: REST API controller class
Last modified: April 25, 2021

---

# REST API controller class

 *  Resolved [SpinoWeb](https://wordpress.org/support/users/spinoweb/)
 * (@spinoweb)
 * [5 years ago](https://wordpress.org/support/topic/rest-api-controller-class/)
 * Hello,
 * I’d want to use a custom php class to control my custom type endpoint in rest
   api.
 * I add php class here, but it does not work:
 *     ```
       function cptui_load_ui_class() {
       	require_once plugin_dir_path( __FILE__ ) . 'classes/class.cptui_admin_ui.php';
       	require_once plugin_dir_path( __FILE__ ) . 'classes/class.cptui_debug_info.php';
   
       	require_once plugin_dir_path( __FILE__ ) . 'classes/class.cptui_rest_controller.php';
       }
       add_action( 'init', 'cptui_load_ui_class' );
       ```
   
 * Do I have to put php class in another folder?

Viewing 3 replies - 1 through 3 (of 3 total)

 *  Plugin Contributor [Michael Beckwith](https://wordpress.org/support/users/tw2113/)
 * (@tw2113)
 * The BenchPresser
 * [5 years ago](https://wordpress.org/support/topic/rest-api-controller-class/#post-14366094)
 * Folder location shouldn’t really matter as long as it’s loaded by the time you’re
   needing to invoke it, so that the class is available to use.
 * Also, you shouldn’t be editing our custom-post-type-ui.php file for this, it’d
   be better off in your active theme’s functions.php file or somewhere else similar.
 *  Thread Starter [SpinoWeb](https://wordpress.org/support/users/spinoweb/)
 * (@spinoweb)
 * [5 years ago](https://wordpress.org/support/topic/rest-api-controller-class/#post-14374315)
 * Thank You!
 *  Plugin Contributor [Michael Beckwith](https://wordpress.org/support/users/tw2113/)
 * (@tw2113)
 * The BenchPresser
 * [5 years ago](https://wordpress.org/support/topic/rest-api-controller-class/#post-14375450)
 * Did you get this working finally? or are you still struggling with the initial
   issue?

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘REST API controller class’ is closed to new replies.

 * ![](https://ps.w.org/custom-post-type-ui/assets/icon-256x256.png?rev=2744389)
 * [Custom Post Type UI](https://wordpress.org/plugins/custom-post-type-ui/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/custom-post-type-ui/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/custom-post-type-ui/)
 * [Active Topics](https://wordpress.org/support/plugin/custom-post-type-ui/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/custom-post-type-ui/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/custom-post-type-ui/reviews/)

 * 3 replies
 * 2 participants
 * Last reply from: [Michael Beckwith](https://wordpress.org/support/users/tw2113/)
 * Last activity: [5 years ago](https://wordpress.org/support/topic/rest-api-controller-class/#post-14375450)
 * Status: resolved