title: Fatal error: Class 'Elementor\Widget_Base' not found
body: <p>I am trying a to add a new widget from my plugin to elementor. I have followed the documentation to how to create an elementor widget: <a href="https://developers.elementor.com/creating-a-new-widget/" rel="nofollow noreferrer">https://developers.elementor.com/creating-a-new-widget/</a></p>
  
  <p>But problem is its not working..
  No#1. When i am using autoload its not showing any error
  No#2. But when i am using <code>require_once</code> its shows a fatal error: <code>Fatal error: Class 'Elementor\Widget_Base' not found</code></p>
  
  <h2>My widget code</h2>
  
  <pre><code>&lt;?php
  namespace WPEVENTCAL\extensions\elementor;
  
  class widget extends \Elementor\Widget_Base {
  
      public function get_name() {
          return 'Aembed';
      }
  
      public function get_title() {
          return __( 'oEmbed', 'plugin-name' );
      }
  
      public function get_icon() {
          return 'fa fa-code';
      }
  
      public function get_categories() {
          return [ 'basic' ];
      }
  
      protected function _register_controls() {
  
          $this-&gt;start_controls_section(
              'content_section',
              [
                  'label' =&gt; __( 'Content', 'plugin-name' ),
                  'tab' =&gt; \Elementor\Controls_Manager::TAB_CONTENT,
              ]
          );
  
          $this-&gt;add_control(
              'url',
              [
                  'label' =&gt; __( 'URL to embed', 'plugin-name' ),
                  'type' =&gt; \Elementor\Controls_Manager::TEXT,
                  'input_type' =&gt; 'url',
                  'placeholder' =&gt; __( 'https://your-link.com', 'plugin-name' ),
              ]
          );
  
          $this-&gt;end_controls_section();
  
      }
  
      protected function render() {
  
          $settings = $this-&gt;get_settings_for_display();
  
          $html = wp_oembed_get( $settings['url'] );
  
          echo '&lt;div class="oembed-elementor-widget"&gt;';
  
          echo ( $html ) ? $html : $settings['url'];
  
          echo '&lt;/div&gt;';
  
      }   
  
  }
  </code></pre>
  
  <h2>My folder structure</h2>
  
  <p><code>-Main plugin file
      -extension
          -elementor
              -widget.php
      - index.php</code></p>
  
  <p>In <code>index.php</code> i am calling <code>require_once( 'extensions/elementor/widget.php' );</code></p>
  
  <p>It throws that error : <code>Fatal error: Class 'Elementor\Widget_Base' not found</code></p>
  
  <p>But when i use autoload function in index it doesn't gives any error neither shows widget</p>
  
  <pre><code>use WPEVENTCAL\extensions\elementor\index;
  function autoload($class = '') {
      if (!strstr($class, 'WPEVENTCAL')) {
          return;
      }
      $result = str_replace('WPEVENTCAL\\', '', $class);
      $result = str_replace('\\', '/', $result);
      require $result . '.php';
  }
  </code></pre>
  
  <p>what may be the problem>?</p>