jeudi 2 novembre 2017

Laravel: use php's ob_flush() to update view

I have a program written in Laravel 5.5 that imports data using a foreign API. That's working. To display the messages in the browser, I use the following code:

public function console( string $message ) {
  ob_implicit_flush(1);
  ob_start();
  echo '<pre>' . $message . '</pre>';
  ob_flush();
  ob_end_flush();
}

So every message I want to display on the screen, I use console("foo"); That works really nice, but this is all without Laravel's View. So how can I pass this stuff to my view, e.g.:

<!doctype html>
<html lang="">
    <head>
        <meta charset="utf-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <meta name="viewport" content="width=device-width, initial-scale=1">

        <title>My App</title>

        <link href="" rel="stylesheet" type="text/css">
        <link rel="shortcut icon" href="/favicon.ico"/>
    </head>
    <body>
        <section class="content">
            @yield( 'content' )
        </section>
    </body>
</html>



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2xNqmen
via IFTTT

Aucun commentaire:

Enregistrer un commentaire