htmlburger / wpemerge-theme

An organized, ES6 and SASS powered theme taking advantage of the WP Emerge framework. 🚀
https://wpemerge.com/
GNU General Public License v2.0
286 stars 33 forks source link

Route handle controller is not called #32

Closed trompx closed 5 years ago

trompx commented 5 years ago

Version

Expected behavior

Home controller home method should be called

Actual behavior

The route is not going through the home controller

Comments

I added in src/Controllers/Web/HomeController.php

<?php
namespace App\Controllers; // with and without
class HomeController {
  public function index( $request, $view ) {
      return WPEmerge\view( 'templates/home' );
  }
}

In routes/web.php, the following is not working Route::get()->url( '/' )->handle( 'HomeController@index' );

while the following return the expected template

Route::get()->url( '/' )->handle( function() {
  return WPEmerge\view( 'templates/home' );
} );

May I suggest you add to the starter theme basic usage like first route + first controller so it is easier for people to start / replace.

trompx commented 5 years ago

The following correct the issue: namespace App\Controllers\Web;

But creates another issue: Call to undefined function App\Controllers\Web\WPEmerge\view()

trompx commented 5 years ago

Using finally works: return \WPEmerge\view( 'templates/home' );

I think adding this simple controller + simple view + simple route in the starter theme or at least having the proper doc would help others.

The doc here https://docs.wpemerge.com/#/framework/0-to-100-setup is confusing as it does not take into account the new folder structure (Controllers/Web-Admin...)

atanas-dev commented 5 years ago

You are correct - the docs are slightly outdated and missing the new directory structure. I will be updating them shortly.

atanas-dev commented 5 years ago

Docs are updated (cache may apply) - let me know if you stumble upon any other inaccuracies: https://docs.wpemerge.com/#/framework/0-to-100-setup