PHP code example of soroosh / ternobo-wire

1. Go to this page and download the library: Download soroosh/ternobo-wire 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/ */

    

soroosh / ternobo-wire example snippets


<!DOCTYPE html>
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}">

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="csrf-token" content="{{ csrf_token() }}">
    <title>Ternobo App</title>
  <link href="/css/app.css" rel="stylesheet" />
</head>

<body class="font-sans antialiased" data-wire='{{ $tuuid }}'>
    {!! $ternoboApp !!}
    <script src="/js/manifest.js" defer></script>
    <script src="/js/vendor.js?" defer></script>
    <script src="/js/app.js" defer></script>
</body>

</html>


use Illuminate\Support\Facades\Route;
use Ternobo\TernoboWire\TernoboWire;

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
 */

TernoboWire::routes();
Route::get('/', "IndexController@index");
// ....



namespace App\Providers;

use Illuminate\Support\ServiceProvider;
use Ternobo\TernoboWire\TernoboWire;
use Illuminate\Support\Facades\Auth;

class AppServiceProvider extends ServiceProvider
{
    /**
     * Register any application services.
     *
     * @return void
     */
    public function register()
    {
        //
    }

    /**
     * Bootstrap any application services.
     *
     * @return void
     */
    public function boot()
    {
        TernoboWire::share(function () {
            return [
            	"appName" => config('app.name'),
				"is_admin" => function (){
					if(Auth::check()){
						return Auth::user()->is_admin;
					}
					return false;
				}
            ];
        });
    }
}