Skip to content

Laravel JS-Settings package provides a command that generate the JavaScript version of all your settings. The resulting JavaScript file will contain all your settings.

License

vildanbina/laravel-js-settings

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Latest Stable Version Total Downloads Latest Unstable Version License PHP Version Require

This package convert all your setting key and values who generated (oriceon/laravel-settings) from your Laravel app to JavaScript with a small library to interact with those settings following a very similar syntax you are familiar with.

Features

  • Support Laravel 5+.
  • Allow to specify desired wildcard keys who will not converted to JS.
  • Settings will generated by package: oriceon/laravel-settings

Installation

composer require vildanbina/laravel-js-settings

In your Laravel app go to config/app.php and add the following service provider:

vildanbina\SettingsJs\LaravelJsSettingsServiceProvider::class

Usage

The Laravel-JS-Settings package provides a command that generate the JavaScript version of all your settings. The resulting JavaScript file will contain all your settings.

Generating JS settings

php artisan settings:js

Specifying a custom target

php artisan settings:js public/assets/dist/settings.dist.js

Compressing the JS file

php artisan settings:js -c

Output a JSON file instead.

php artisan settings:js --json

Configuration

First, publish the default package's configuration file running:

php artisan vendor:publish --provider="vildanbina\SettingsJs\LaravelJsSettingsServiceProvider"

The configuration will be published to config/settings-js.php.

You may edit this file to define the setting key you exclude in your Javascript code. Just edit the exclude_keys array in the config file.

<?php

return [
    'exclude_keys' => [
        'smtp_*', 
    ],
];

Documentation

This is a quick documentation regarding this package

Getting a setting

Settings.get('foo');

Getting a setting with default value

Settings.get('foo', 'bar');

Checking if a setting key exists

Settings.has('foo');

Prerequisites:

You will need to have installed the following softwares.

  • Composer.
  • PHP 7+.

Development setup

After getting all the required softwares you may run the following commands to get everything ready:

  1. Install PHP dependencies:
    composer install

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please e-mail vildanbina@gmail.com to report any security vulnerabilities instead of the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.

About

Laravel JS-Settings package provides a command that generate the JavaScript version of all your settings. The resulting JavaScript file will contain all your settings.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published