php-soft/laravel-array-view

Laravel Array View
12,539 3
Install
composer require php-soft/laravel-array-view
Latest Version:v1.1.4
PHP:>=5.5.9
License:MIT
Last Updated:Feb 25, 2016
Links: GitHub  ·  Packagist
Maintainer: huytbt

Laravel Array View

Build Status

An array view engine for Laravel PHP Framework.

Version Compatibility

ArrayView Laravel
1.0.x 5.1.x
1.1.x 5.1.x
1.1.4 5.*

Installation

$ composer require php-soft/laravel-array-view

Once this has finished, you will need to add the service provider to the providers array in your app.php config as follows:

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

Next, also in the app.php config file, under the aliases array, you may want to add facades.

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

Usage

Code in controller (Example routes.php)

<?php

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

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

views/article.array.php

<?php

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

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

This template generates the following object:

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

Functions

Reference to https://github.com/huytbt/php-array-view#functions

Related Packages

repat/laravel-helper

Some helper function for developing applications in laravel

5,705 5
mojopollo/laravel-helpers

Mojo's Laravel Helpers: A suite of various helpers for use in Laravel 5.0 / 5.1...

561 0
elvedia/vsentry

A Laravel4 Sentry2 view helper set.

26 1
propaganistas/laravel-helper-macros

Useful helpers and macros for Laravel 5.

63 16
faisalahsanse/laravel-breadcrums

A helper function to create breadcrums for you website

16 2