dev-master
9999999-devSave array-return configuration files in Laravel 4.
MIT
The Requires
v0.9
0.9.0.0Save array-return configuration files in Laravel 4.
MIT
The Requires
Save array-return configuration files in Laravel 4.
perm offers a simple way to save and retrieve "native" php configuration files in the filesystem., (*2)
For example, if writing a cms like Vessel, you might want to save fast configuration values (like a site title or url) perm-anently from an admin interface. This is easy with perm., (*3)
perm installs with Composer through Packagist., (*4)
Add the following to your composer.json:, (*5)
{ "require": { "andrewsuzuki/perm": "dev-master", } }
Then run composer update
., (*6)
Now add the following to your providers
array in config/app.php:, (*7)
'Andrewsuzuki\Perm\PermServiceProvider',
Now add the facade alias to the aliases
array:, (*8)
'Perm' => 'Andrewsuzuki\Perm\Facades\Perm',
And that's it., (*9)
If you'd like to load/save files from a base directory other than app/config, publish the package's configuration:, (*10)
php artisan config:publish hokeo/vessel
Then modify the basepath in app/config/packages/andrewsuzuki/perm/config.php., (*11)
// dot notation from base path (see above for configuration) $perm = Perm::load('profile.andrew'); // ...or absolute path (no extension) $perm = Perm::load('/path/to/file');
If the file's directory does not exist, it will be created., (*12)
$location = $perm->get('location'); $location = $perm->location; // for the first level, you can use magic properties $first_name = $perm->get('name.first'); // use dot notation for nested values
$locationAndFirstName = $perm->get(array('location', 'name.first')); // or... list($location, $firstName) = $perm->get(array('location', 'name.first'));
$config = $perm->all();
$perm->set('timezone', 'UTC'); // for the first level, you can use magic properties $perm->timezone = 'UTC';
$perm->setIf('timezone', 'UTC');
$perm->set(array('timezone' => 'UTC', 'location' => 'Earth'));
$exists = $perm->has('location'); // true/false $exists = $perm->has('name.first'); // true/false
$perm->forget('location');
$perm->reset();
$perm->save();
$perm->setFilename('/path/to/new/file'); // then you might set some more values, then call ->save() again, etc...
Chaining methods is an easy way to consolidate, and improve readability. You can combine any of the above methods marked as chainable. For example:, (*13)
Perm::load('profile.andrew')->set('name', 'Andrew')->forget('location')->save();
To contribute, please fork and submit a pull request. Otherwise, feel free to submit possible enhancements/issues on the issues page., (*14)
Vessel is open-sourced software licensed under the MIT license, (*15)
Save array-return configuration files in Laravel 4.
MIT
Save array-return configuration files in Laravel 4.
MIT