title: Magento 2.1.1 Invalid block type exception - class not found
body: <p>Trying to load a custom module's edit/create form.</p>
  
  <p>In my <strong>Magento 2.1.1</strong> on my production system (linux) I get a invalid block type exception caused by class not found while on my local host xampp / windows all works fine.
  It occurs when I want to open the form to create or edit a custom entity while the grid works fine.</p>
  
  <pre><code>2 exception(s):
  Exception #0 (Magento\Framework\Exception\LocalizedException): Invalid block type: Brainworx\Medipimsync\Block\Adminhtml\Sync\Edit\Form
  Exception #1 (ReflectionException): Class Brainworx\Medipimsync\Block\Adminhtml\Sync\Edit\Form does not exist
  
  Exception #0 (Magento\Framework\Exception\LocalizedException): Invalid block type: Brainworx\Medipimsync\Block\Adminhtml\Sync\Edit\Form
  #0 /data/sites/web/apovitabe/www/vendor/magento/framework/View/Layout/Generator/Block.php(237): Magento\Framework\View\Layout\Generator\Block-&gt;getBlockInstance('Brainworx\\Medip...', Array)
  #1 /data/sites/web/apovitabe/www/vendor/magento/framework/View/Layout.php(760): Magento\Framework\View\Layout\Generator\Block-&gt;createBlock('Brainworx\\Medip...', 'medipimsync_syn...', Array)
  #2 /data/sites/web/apovitabe/www/vendor/magento/framework/View/Layout.php(743): Magento\Framework\View\Layout-&gt;_createBlock('Brainworx\\Medip...', 'medipimsync_syn...', Array)
  #3 /data/sites/web/apovitabe/www/var/generation/Magento/Framework/View/Layout/Interceptor.php(349): Magento\Framework\View\Layout-&gt;createBlock('Brainworx\\Medip...', 'medipimsync_syn...', Array)
  #4 /data/sites/web/apovitabe/www/vendor/magento/framework/View/Element/AbstractBlock.php(382): Magento\Framework\View\Layout\Interceptor-&gt;createBlock('Brainworx\\Medip...', 'medipimsync_syn...', Array)
  #5 /data/sites/web/apovitabe/www/vendor/magento/module-backend/Block/Widget/Form/Container.php(108): Magento\Framework\View\Element\AbstractBlock-&gt;addChild('form', 'Brainworx\\Medip...')
  #6 /data/sites/web/apovitabe/www/vendor/magento/framework/View/Element/AbstractBlock.php(264): Magento\Backend\Block\Widget\Form\Container-&gt;_prepareLayout()
  #7 /data/sites/web/apovitabe/www/vendor/magento/framework/View/Layout/Generator/Block.php(139): Magento\Framework\View\Element\AbstractBlock-&gt;setLayout(Object(Magento\Framework\View\Layout\Interceptor))
  #8 /data/sites/web/apovitabe/www/vendor/magento/framework/View/Layout/GeneratorPool.php(86): Magento\Framework\View\Layout\Generator\Block-&gt;process(Object(Magento\Framework\View\Layout\Reader\Context), Object(Magento\Framework\View\Layout\Generator\Context))
  #9 /data/sites/web/apovitabe/www/vendor/magento/framework/View/Layout.php(327): Magento\Framework\View\Layout\GeneratorPool-&gt;process(Object(Magento\Framework\View\Layout\Reader\Context), Object(Magento\Framework\View\Layout\Generator\Context))
  #10 /data/sites/web/apovitabe/www/var/generation/Magento/Framework/View/Layout/Interceptor.php(89): Magento\Framework\View\Layout-&gt;generateElements()
  #11 /data/sites/web/apovitabe/www/vendor/magento/framework/View/Layout/Builder.php(129): Magento\Framework\View\Layout\Interceptor-&gt;generateElements()
  #12 /data/sites/web/apovitabe/www/vendor/magento/framework/View/Page/Builder.php(55): Magento\Framework\View\Layout\Builder-&gt;generateLayoutBlocks()
  #13 /data/sites/web/apovitabe/www/vendor/magento/framework/View/Layout/Builder.php(65): Magento\Framework\View\Page\Builder-&gt;generateLayoutBlocks()
  #14 /data/sites/web/apovitabe/www/vendor/magento/framework/View/Layout.php(244): Magento\Framework\View\Layout\Builder-&gt;build()
  #15 /data/sites/web/apovitabe/www/vendor/magento/framework/View/Layout.php(859): Magento\Framework\View\Layout-&gt;build()
  #16 /data/sites/web/apovitabe/www/var/generation/Magento/Framework/View/Layout/Interceptor.php(414): Magento\Framework\View\Layout-&gt;getBlock('menu')
  #17 /data/sites/web/apovitabe/www/vendor/magento/module-backend/Model/View/Result/Page.php(59): Magento\Framework\View\Layout\Interceptor-&gt;getBlock('menu')
  #18 /data/sites/web/apovitabe/www/var/generation/Magento/Backend/Model/View/Result/Page/Interceptor.php(24): Magento\Backend\Model\View\Result\Page-&gt;setActiveMenu('Brainworx_Medip...')
  #19 /data/sites/web/apovitabe/www/app/code/brainworx/medipimsync/Controller/Adminhtml/Sync/Edit.php(52): Magento\Backend\Model\View\Result\Page\Interceptor-&gt;setActiveMenu('Brainworx_Medip...')
  #20 /data/sites/web/apovitabe/www/app/code/brainworx/medipimsync/Controller/Adminhtml/Sync/Edit.php(87): brainworx\medipimsync\Controller\Adminhtml\Sync\Edit-&gt;_initAction()
  #21 /data/sites/web/apovitabe/www/var/generation/brainworx/medipimsync/Controller/Adminhtml/Sync/Edit/Interceptor.php(24): brainworx\medipimsync\Controller\Adminhtml\Sync\Edit-&gt;execute()
  #22 /data/sites/web/apovitabe/www/vendor/magento/framework/App/Action/Action.php(102): brainworx\medipimsync\Controller\Adminhtml\Sync\Edit\Interceptor-&gt;execute()
  #23 /data/sites/web/apovitabe/www/vendor/magento/module-backend/App/AbstractAction.php(226): Magento\Framework\App\Action\Action-&gt;dispatch(Object(Magento\Framework\App\Request\Http))
  #24 /data/sites/web/apovitabe/www/vendor/magento/framework/Interception/Interceptor.php(74): Magento\Backend\App\AbstractAction-&gt;dispatch(Object(Magento\Framework\App\Request\Http))
  #25 /data/sites/web/apovitabe/www/vendor/magento/framework/Interception/Chain/Chain.php(70): brainworx\medipimsync\Controller\Adminhtml\Sync\Edit\Interceptor-&gt;___callParent('dispatch', Array)
  #26 /data/sites/web/apovitabe/www/vendor/magento/framework/Interception/Chain/Chain.php(63): Magento\Framework\Interception\Chain\Chain-&gt;invokeNext('brainworx\\medip...', 'dispatch', Object(brainworx\medipimsync\Controller\Adminhtml\Sync\Edit\Interceptor), Array, 'adminAuthentica...')
  </code></pre>
  
  <p><strong><em>Setup:</em></strong></p>
  
  <p><strong>registion.php</strong></p>
  
  <pre><code>\Magento\Framework\Component\ComponentRegistrar::register(
          \Magento\Framework\Component\ComponentRegistrar::MODULE,
          'brainworx_medipimsync',
          __DIR__
  );
  </code></pre>
  
  <p><strong>etc/Module.xml</strong></p>
  
  <pre><code>&lt;?xml version="1.0"?&gt;
      &lt;config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd"&gt;
          &lt;module name="brainworx_medipimsync" setup_version="1.0.4" /&gt;
      &lt;/config&gt;
  </code></pre>
  
  <p><strong>Form class exists:</strong> app\code\brainworx\medipimsync\Block\Adminhtml\Sync\Edit\Form.php</p>
  
  <pre><code>namespace brainworx\medipimsync\Block\Adminhtml\Sync\Edit;
  
  use Magento\Backend\Block\Template\Context;
  use Magento\Framework\Registry;
  use Magento\Framework\Data\FormFactory;
  use Magento\Store\Model\System\Store;
  use Magento\Backend\Model\Auth\Session;
  
  /**
   * Adminhtml sync edit form
   */
  class Form extends \Magento\Backend\Block\Widget\Form\Generic
  {
  
      /**
       * @var \Magento\Store\Model\System\Store
       */
      protected $_systemStore;
      protected $_loginUser;
  
      /**
       * @param \Magento\Backend\Block\Template\Context $context
       * @param \Magento\Framework\Registry $registry
       * @param \Magento\Framework\Data\FormFactory $formFactory
       * @param \Magento\Cms\Model\Wysiwyg\Config $wysiwygConfig
       * @param \Magento\Store\Model\System\Store $systemStore
       * @param array $data
       * @param \Magento\backend\Model\Auth\Session $authSession
       */
      public function __construct(
              Context $context,Registry $registry,FormFactory $formFactory,Store $systemStore,
              array $data = [],Session $authSession
      ) {
          $this-&gt;_systemStore = $systemStore;
          $this-&gt;_loginUser = $authSession-&gt;getUser()-&gt;getUsername();
          parent::__construct($context, $registry, $formFactory, $data);
      }
  
      /**
       * Init form
       *
       * @return void
       */
      protected function _construct()
      {
          parent::_construct();
          $this-&gt;setId('sync_form');
          $this-&gt;setTitle(__('Sync Information'));
      }
  
      /**
       * Prepare form
       *
       * @return $this
       */
      protected function _prepareForm()
      {       
          /** @var \brainworx\medipimsync\Model\Sync $model */
          $model = $this-&gt;_coreRegistry-&gt;registry('medipimsync_sync');
  
          /** @var \Magento\Framework\Data\Form $form */
          $form = $this-&gt;_formFactory-&gt;create(
                  ['data' =&gt; ['id' =&gt; 'edit_form','action' =&gt; $this-&gt;getData('action'), 'method' =&gt; 'post']]
          );
  
          $form-&gt;setHtmlIdPrefix('sync_');
  
          $fieldset = $form-&gt;addFieldset(
                  'base_fieldset',
                  ['legend' =&gt; __('General Information'), 'class' =&gt; 'fieldset-wide']
          );
  
          $fieldset-&gt;addField(
                  'title',
                  'text',
                  ['name' =&gt; 'user', 'label' =&gt; __('User'), 'title' =&gt; __('User'), 'required' =&gt; true,
                          'value' =&gt; $this-&gt;_loginUser , 'readonly' =&gt; true
                  ]
          );
  
          $fieldset-&gt;addField(
                  'entity',
                  'select',
                  [
                          'label' =&gt; __('Entity'),
                          'title' =&gt; __('Entity'),
                          'name' =&gt; 'entity',
                          'required' =&gt; true,
                          'options' =&gt; ['PROD' =&gt; __('Products'), 'CAT' =&gt; __('Categories')]
                  ]
          );
  
          //$form-&gt;setValues($model-&gt;getData());
          $form-&gt;setUseContainer(true);
          $this-&gt;setForm($form);
  
          return parent::_prepareForm();
      }
  }
  </code></pre>
  
  <p><strong>edit class</strong>
  Also the edit class containing the form
  app\code\brainworx\medipimsync\Block\Adminhtml\Sync\Edit.php</p>
  
  <pre><code>namespace brainworx\medipimsync\Block\Adminhtml\Sync;
  
  class Edit extends \Magento\Backend\Block\Widget\Form\Container
  {
      /**
       * Core registry
       *
       * @var \Magento\Framework\Registry
       */
      protected $_coreRegistry = null;
  
      /**
       * @param \Magento\Backend\Block\Widget\Context $context
       * @param \Magento\Framework\Registry $registry
       * @param array $data
       */
      public function __construct(
              \Magento\Backend\Block\Widget\Context $context,
              \Magento\Framework\Registry $registry,
              array $data = []
      ) {
          $this-&gt;_coreRegistry = $registry;
          parent::__construct($context, $data);
      }
  
      /**
       * Initialize blog post edit block
       *
       * @return void
       */
      protected function _construct()
      {
          $this-&gt;_objectId = 'sync_id';
          $this-&gt;_blockGroup = 'brainworx_medipimsync';
          $this-&gt;_controller = 'adminhtml_sync';
  
          parent::_construct();
  
          if ($this-&gt;_isAllowedAction('Brainworx_Medipimsync::save')) {
              $this-&gt;buttonList-&gt;update('save', 'label', __('Creatae new'));
              $this-&gt;buttonList-&gt;add(
                      'saveandcontinue',
                      [
                              'label' =&gt; __('Save and Continue Edit'),
                              'class' =&gt; 'save',
                              'data_attribute' =&gt; [
                                      'mage-init' =&gt; [
                                              'button' =&gt; ['event' =&gt; 'saveAndContinueEdit', 'target' =&gt; '#edit_form'],
                                      ],
                              ]
                      ],
                      -100
              );
          } else {
              $this-&gt;buttonList-&gt;remove('save');
          }
      }
  
      /**
       * Retrieve text for header element depending on loaded post
       *
       * @return \Magento\Framework\Phrase
       */
      public function getHeaderText()
      {
          if ($this-&gt;_coreRegistry-&gt;registry('medipim_sync')-&gt;getId()) {
              return __("Edit Sync '%1'", $this-&gt;escapeHtml($this-&gt;_coreRegistry-&gt;registry('medipimsync_sync')-&gt;getTitle()));
          } else {
              return __('New Sync');
          }
      }
  
      /**
       * Check permission for passed action
       *
       * @param string $resourceId
       * @return bool
       */
      protected function _isAllowedAction($resourceId)
      {
          return $this-&gt;_authorization-&gt;isAllowed($resourceId);
      }
  
      /**
       * Getter of url for "Save and Continue" button
       * tab_id will be replaced by desired by JS later
       *
       * @return string
       */
      protected function _getSaveAndContinueUrl()
      {
          return $this-&gt;getUrl('medipimsync/*/save', ['_current' =&gt; true, 'back' =&gt; 'edit', 'active_tab' =&gt; '']);
      }
  }
  </code></pre>
  
  <p><strong>Layout file</strong>
  And the layout file loading the edit class: view/adminhtml/layout/medipimsync_sync_edit.xml</p>
  
  <pre><code>&lt;page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd"&gt;
      &lt;update handle="editor"/&gt;
      &lt;body&gt;
          &lt;referenceContainer name="content"&gt;
              &lt;block class="brainworx\medipimsync\Block\Adminhtml\Sync\Edit" name="medipimsync_sync_edit"/&gt;
          &lt;/referenceContainer&gt;
      &lt;/body&gt;
  &lt;/page&gt;
  </code></pre>
  
  <p><em>Thanks for the help!</em></p>