getherbert / herbert

The WordPress Plugin Framework:
http://getherbert.com/
634 stars 95 forks source link

No view with controller #163

Closed ElodieBerthaud closed 7 years ago

ElodieBerthaud commented 7 years ago

Hello,

I'd like to return a view from my controller:

controller.php:

namespace FormulaireClient\Controllers;

class FormulaireController
{
    function __construct()
    {

    }

    public function showView()
    {
        return view('@FormulaireClient/formulaire.twig', [
        'title'     =>  'formulaire',
        'content'   =>  'répondez à ce court questionnaire'
        ]);
    }
}

routes.php:

namespace FormulaireClient;

$router->get([
    'as'    => 'simpleRoute',
    'uri'   => '/formulaire',
'uses'  =>  __NAMESPACE__ . '\Controllers\FormulaireController@showView'
]);

formulaire.twig:

<div>TEST</div>

The router works fine but when I use a controller to get the view, I've got nothing wrote on the screen. But if I just have a simple route without using a controller (just like for exemple: return 'Hello World'), that works fine.

Sorry for bad English, I'm French.

I hope that you could have some answers for me...

thank you in advance :)

ps: I'm beginner in programing, so sorry for mistakes I could make.

ken-bem commented 7 years ago

Do you get a blank screen or the word test?

ElodieBerthaud commented 7 years ago

Thks for your answer!

I've got a blank screen. Nothing in my formulaire.twig is posted.

ElodieBerthaud commented 7 years ago

I've found the issue! The mistake is from me ... I had my 'vews' folder was named 'view'.

It was all my fault.

Sorry for this!

ken-bem commented 7 years ago

That what i was going to suggest, to check folder path, good that you resolved ! :)

ElodieBerthaud commented 7 years ago

Thank you !

jeremyzahner commented 7 years ago

@ElodieBerthaud Thanks for using Herbert. I'm closing this issue since it seems to be resolved for you. Feel free to reopen it if thats not the case.