PHP code example of codersandip / laravel-dynamic-settings
1. Go to this page and download the library: Download codersandip/laravel-dynamic-settings 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/ */
codersandip / laravel-dynamic-settings example snippets
// Get a setting
setting('site_name'); // → 'My Application'
// Get with a default value
setting('site_name', 'Default App'); // → 'Default App' if not set
// Get with tenant context (falls back to global if not found)
setting('currency', 'USD', $tenantId);
// Get with tenant + user context
setting('theme', 'light', $tenantId, $userId);
// Via helper (chained)
setting()->set('site_name', 'My App');
// With options
setting()->set('page_size', 20, [
'type' => 'integer',
'group' => 'general',
'description' => 'Results per page',
]);
use Codersandip\DynamicSettings\Facades\Settings;
Settings::get('site_name');
Settings::get('site_name', 'Default');
Settings::set('site_name', 'New Name');
Settings::delete('site_name');
Settings::has('site_name');
use Codersandip\DynamicSettings\Services\SettingsService;
class MyController extends Controller
{
public function __construct(private SettingsService $settings) {}
public function index()
{
$siteName = $this->settings->get('site_name', 'My App');
// ...
}
}