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

Cannot load view #7

Closed atanas-dev closed 6 years ago

atanas-dev commented 6 years ago

@sinegrain commented on Thu Aug 02 2018

Hi guys i'm trying to integrate htmlburger/wpemerge-blade with wp-emerge-theme but cannot getting to work. i installed htmlburger/wpemerge-blade with composer and i added the service provider to config.php

here is my "app/config.php"

<?php
/**
 * WP Emerge configuration.
 *
 * @see  https://docs.wpemerge.com/configuration.html
 */

return [
    /**
     * Array of service providers you wish to enable.
     */
    'providers'         => [
        \WPEmergeBlade\View\ServiceProvider::class
    ],
    /**
     * Array of global middleware to apply to all requests.
     */
    'global_middleware' => [

    ],

    /**
     * Other config goes after this comment.
     */

];

Here is my "app/src/controllers/MainController.php"


<?php

namespace App\Controllers;

use WPEmerge\Requests\Request;

class MainController {
    public function home( Request $request, $view ) {
        // Add back-end logic here
        // for example, prepare some variables to pass to the view
        // or validate request parameters etc.
        $name = 'foobar';

        // return app_output( 'Hello World!' ); //this line uncommented work and i see the message

                 //I tried also templates/baselayout || templates/baselayout.blade.php 
        return app_view( 'templates.baselayout' ) 
            ->with( [
                'name' => $name,
            ] );
    }
}

Here is my view "theme/template/baselayout.blade.php"

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Test WP-Emerge</title>
</head>
<body>
    <p>Hello {{$name}}!!!</p>
    @yeld('content')
</body>
</html>

Here is myb "app/framework.php"


<?php
/**
 * ------------------------------------------------------------------------
 * Routes
 *
 * @see https://docs.wpemerge.com/routing/methods.html
 * ------------------------------------------------------------------------
 */

// Using our ExampleController to handle the homepage, for example.

Router::get( '/', 'App\Controllers\MainController@home' );

// If we do not want to hardcode a url, we can use one of the available route conditions instead:
/*
Router::get( ['post_id', get_option( 'page_on_front' )], 'App\Controllers\ExampleController@home' );
*/

/**
 * Pass all front-end requests through WPEmerge.
 * WARNING: Do not add routes after this - they will be ignored.
 *
 * @see https://docs.wpemerge.com/routing/methods.html#handling-all-requests
 */
Router::handleAll();

/**
 * ------------------------------------------------------------------------
 * Globals
 *
 * @see https://docs.wpemerge.com/view/global-context.html
 * ------------------------------------------------------------------------
 */

/*
View::addGlobal( 'foo', 'bar' );
 */

/**
 * ------------------------------------------------------------------------
 * View composers
 *
 * @see https://docs.wpemerge.com/view/view-composers.html
 * ------------------------------------------------------------------------
 */

/*
View::addComposer( 'partials/foo', \App\ViewComposers\FooPartialViewComposer::class );
 */

When i load the page i receive ERR_EMPTY_RESPONSE

I am doing something wrong or i miss a config?


@atanas-angelov-dev commented on Thu Aug 02 2018

Hi @sinegrain ,

I believe you are affected by an old bug - please update to the latest versions of everything (wpemerge-theme, wpemerge, wpemerge-blade). Since the theme is setup using composer create-project the simplest solution would be to re-setup it the same way.

After that, restart your webserver and give it another try. If you still have the same error after doing that please submit your composer.lock so I can double check the versions installed.

PS: You have a couple of typos - these are not the cause for the problem, but wanted to mention them so they don't muddy the results:

ghost commented 6 years ago

Ok after composer update it works. Thank you