1. Go to this page and download the library: Download tightenco/laravel-elm library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
tightenco / laravel-elm example snippets
Route::get('/', function () {
return Elm::render('Welcome');
});
Route::get('/', function () {
return Elm::render('Welcome', ['name' => 'John']);
});
use Tightenco\Elm\Elm;
...
public function boot()
{
...
Elm::share('user', function () {
return auth()->user() ? [
'id' => auth()->user()->id,
'name' => auth()->user()->name,
] : null;
});
}
...
Route::get('/', function () {
return Elm::render('Welcome');
})->name('welcome');
namespace Tests;
use Illuminate\Foundation\Testing\TestCase as BaseTestCase;
abstract class TestCase extends BaseTestCase
{
use CreatesApplication;
public function setUp(): void
{
parent::setUp();
$this->withHeaders(['X-Laravel-Elm' => 'true']);
}
}