PHP code example of bonsaicms / serve-spa

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

    

bonsaicms / serve-spa example snippets




return [

    /*
    |--------------------------------------------------------------------------
    | Array of Single Page Applications
    |--------------------------------------------------------------------------
    |
    | You can define multiple items here.
    |
    */

    'serve' => [

        /*
        |--------------------------------------------------------------------------
        | Example SPA
        |--------------------------------------------------------------------------
        */

        [

            /*
            |--------------------------------------------------------------------------
            | Name of the Route Serving the SPA
            |--------------------------------------------------------------------------
            */

            'routeName' => 'spa',

            /*
            |--------------------------------------------------------------------------
            | Route Configuration
            |--------------------------------------------------------------------------
            |
            | This configuration will be applied only for this SPA.
            |
            */

            'routeConfig' => [
                'prefix' => 'spa',
            ],

            /*
            |--------------------------------------------------------------------------
            | Response
            |--------------------------------------------------------------------------
            |
            | Example values:
            |
            |  - 'someViewName'
            |  - 'MyController@myMethod'
            |  - [ MyController::class, 'myMethod' ]
            |  - function () { return 'my custom response'; }
            |
            */

            'response' => 'spa',

        ],
    ],

    /*
    |--------------------------------------------------------------------------
    | Global Route Configuration
    |--------------------------------------------------------------------------
    |
    | This configuration will be applied for all defined SPAs.
    |
    */

    'globalRoutesConfig' => [
        'middleware' => 'web',
    ],
];
bash2
$ php artisan vendor:publish --tag=serve-spa