Skip to content
No description, website, or topics provided.
PHP Elm
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
src
.gitignore
LICENSE
composer.json
laravel-elm-banner.png
readme.md

readme.md

Laravel Elm logo

Render your Elm programs from Laravel

So you want to render multiple elm programs inside a laravel application?

This package makes it seamless.

Required: The partner Javascript library with the same name, npm i laravel-elm --save-dev

https://github.com/loganhenson/laravel-elm

Add the elm runner to your webpack.mix.js e.g.:

const mix = require('laravel-mix');
const elm = require('laravel-elm');

mix.js('resources/js/app.js', 'public/js')
    .sass('resources/sass/app.scss', 'public/css')
    .then(elm);

Installation

composer require tightenco/laravel-elm

Create your first Elm application

php artisan elm:create Example

Watch your elm files just like you would everything else

npm run watch

You may then use the Elm facade to view your Elm apps.

use Tightenco\Elm\Elm;
...
public function index()
{
    return view('home', [
        'Example' => Elm::make('Example'),
    ]);
}

And then render it in your view:

{!! $Example !!}

Hello, World!

You can even pass flags to your Elm application

You can generate a program with flags via php artisan elm:create Example --with-flags

use Tightenco\Elm\Elm;
...
public function index()
{
    return view('home', [
        'Example' => Elm::make('Example', [
            'value' => 'Hello, World!'
            // You can pass anything you might need:
            // 'csrfToken' => csrf_token(),
            // 'user' => auth()->user(),
        ]),
    ]);
}

License

View the license for this repo.

You can’t perform that action at this time.