laravel-config-js maintained by stri8ed
Description
Laravel package for exposing configs in JS
Author
Last update
2024/11/20 14:52
(v1.0.2)
License
Downloads
254
Laravel Config JS
A Laravel package that exposes your Laravel configuration values to JavaScript.
Installation
composer require stri8ed/laravel-config-js
Usage
In your Blade views, use the @configJs directive to expose specific config values:
@configJs('app.name')
This creates a global laravelConfig() function that you can use in JavaScript:
// Get a single config value
const appName = laravelConfig('app.name');
// With a default value
const debug = laravelConfig('app.debug', false);
You can expose multiple config values:
@configJs(['app.name', 'app.env', 'services.api.key'])
Configuration
Optionally publish the config file to customize the JavaScript function name:
php artisan vendor:publish --tag="config-js"
License
MIT