PHP code example of php-soft / laravel-array-view

1. Go to this page and download the library: Download php-soft/laravel-array-view 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/ */

    

php-soft / laravel-array-view example snippets


'providers' => [
    // ...
    PhpSoft\ArrayView\Providers\ArrayViewServiceProvider::class,
]

'aliases' => [
    // ...
    'ArrayView' => PhpSoft\ArrayView\Facades\ArrayView::class,
]



Route::get('/articles/{id}', function ($id) {

    $article = Article::find($id);
    return response()->json(arrayView('article', [ 'article' => $article ]));
});



$this->set('title', $article->title);
$this->set('author', function ($section) use ($article) {

    $section->set('name', $article->author->name);
});

[
    'title' => 'Example Title',
    'author' => [
        'name' => 'John Doe'
    ]
]
sh
$ composer