PHP code example of mpbarlow / laravel-vue-component-helper
1. Go to this page and download the library: Download mpbarlow/laravel-vue-component-helper 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/ */
mpbarlow / laravel-vue-component-helper example snippets
// MyController.php
public function index()
{
vue()
->register('UserIndex', ['users' => $users]);
->register('AnotherComponent')
return view('layout');
}
// MyController.php
public function index()
{
vue()->register('UserIndex', ['users' => $users], 'js/components.js');
return view('layout');
}
[
/*
|-----------------------------------------------------
| Default Blade template
|-----------------------------------------------------
|
| Specify the Blade template to render (as you would pass to the view()
| helper or View::make()) when no explicit template is supplied.
| e.g. 'layout' would refer to 'resources/views/layout.blade.php'
|
*/
'default_template' => 'layout',
/*
|-----------------------------------------------------
| Default $mount element
|-----------------------------------------------------
|
| The selector for the DOM element that a component should be mounted to
| if none is supplied.
|
*/
'default_mount_el' => '#app',
/*
|-----------------------------------------------------
| Default variable assignment
|-----------------------------------------------------
|
| The default JavaScript variable that the new Vue instance is assigned to.
| Leave null if you don't want to assign a variable.
|
*/
'default_variable' => null,
/*
|-----------------------------------------------------
| Use Laravel Mix for dependencies
|-----------------------------------------------------
|
| If true, any registered dependencies for a component will be wrapped in
| mix() calls.
|
*/
'use_mix' => true,
/*
|-----------------------------------------------------
| Vue global
|-----------------------------------------------------
|
| The name of the global Vue object (i.e. 'new Vue(...)')
|
*/
'vue_global' => 'Vue',
/*
|-----------------------------------------------------
| Additional configuration
|-----------------------------------------------------
|
| Additional configuration data to pass into the Vue constructor when
| mounting components. If you need to register a Vuex store or Vue router,
| this is the place to specify it.
| e.g. to specify a Vuex store called myStore, set this to
| ['store' => 'myStore']
|
| This only supports one-dimensional arrays for now, so if you need nested
| objects or functions, you'll need to type them out as a string.
|
*/
'additional_config' => [],
];