# Class 'my_widget' not found in widget.php

**URL:** https://discourse.roots.io/t/class-my-widget-not-found-in-widget-php/4669
**Category:** sage
**Created:** 2015-09-03T11:23:56Z
**Posts:** 5
**Showing post:** 2 of 5

## Post 2 by @kalenjohnson — 2015-09-03T16:32:44Z

> [@Is your function or hook not working in Sage? Read this](https://discourse.roots.io/t/is-your-hook-not-working-in-sage-read-this/3376):
>
> If you’re getting an error about call\_user\_func\_array(), chances are you are trying to use a function in the lib directory as a hook or filter and are not passing the namespace along with it. Please read this blog post to get an idea of what namespaces are and how to use them:

`add_action( 'widgets_init', __NAMESPACE__. '\\wpb_load_widget' );` is correct, you’re passing the namespace.

`class my_widget extends \WP_Widget` is correct, you need to make sure PHP is looking for `WP_Widget` in the global namespace.

`register_widget( 'my_widget' );` missing namespace

---

_[View the full topic](https://discourse.roots.io/t/class-my-widget-not-found-in-widget-php/4669)._
