PHP code example of mxent / pwax

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

    

mxent / pwax example snippets


return [
    'hash_route'   => false,            // hash (#/) vs history routing
    'home'         => 'index',          // fallback named route
    'route_prefix' => '__pwax__',       // internal asset prefix

    'blade' => [
        'content' => null, 'head' => null, 'foot' => null,
        'error' => null, 'loader' => null,
    ],

    'customization' => [
        'init_spinner_color' => '#0c83ff',
        'init_spinner_bg'    => '#f3f3f3',
    ],

    'styles'  => [],
    'scripts' => [
        'https://unpkg.com/[email protected]/dist/vue.global.prod.js',
        'https://unpkg.com/[email protected]/dist/vue-router.global.prod.js',
        'https://unpkg.com/[email protected]/dist/pinia.iife.prod.js',
    ],

    'plugins'    => [],
    'directives' => [],
    'middleware' => [],

    'cache' => [
        'asset_ttl' => 3600,            // .js/.css cache lifetime
    ],

    'manifest_path' => '/manifest.webmanifest',
    'manifest' => [                     // Web App Manifest fields
        'name'        => env('APP_NAME', 'Pwax App'),
        'short_name'  => env('APP_NAME', 'Pwax'),
        'start_url'   => '/',
        'display'     => 'standalone',
        'theme_color' => '#0c83ff',
        'icons'       => [/* { src, sizes, type } */],
    ],

    'service_worker' => [
        'enabled'       => false,       // turn on to register /service-worker.js
        'path'          => '/service-worker.js',
        'cache_name'    => 'pwax-cache-v1',
        'precache'      => ['/'],
        'network_first' => true,
    ],
];

use Illuminate\Http\Request;

class HomeController extends Controller
{
    public function index()
    {
        return vue('components.hello');
    }
    
    public function profile()
    {
        return vue('components.profile', [
            'user' => auth()->user()
        ]);
    }
}

Route::get('/', [HomeController::class, 'index'])->name('index');
Route::get('/profile', [HomeController::class, 'profile'])->name('profile');
Route::get('/about', [HomeController::class, 'about'])->name('about');

'plugins' => [
    [
        'name' => 'myPlugin',
        'init' => 'app.use(MyCustomPlugin, { option: "value" })'
    ]
],

'directives' => [
    [
        'name' => 'focus',
        'init' => 'app.directive("focus", { mounted(el) { el.focus() } })'
    ]
],

'middleware' => [
    [
        'name' => 'auth',
        'init' => 'if (!user.isAuthenticated) { window.location = "/login" }'
    ]
],
bash
php artisan pwax:install
bash
php artisan vendor:publish --tag=pwax-config
bash
php artisan vendor:publish --tag=pwax-service-worker
bash
php artisan vendor:publish --tag=pwax-views