acidjazz / larjectus
Adds the power of objectus to Laravel and Lumen
Requires
- php: >=5.6.25
- codacy/coverage: ^1.0
Requires (Dev)
- orchestra/testbench: ^3.3
- satooshi/php-coveralls: ^1.0
README
Allows you to use Objectus seamlessly in Laravel 5 and Lumen
What this does
- Combines your
.env
andconfig/
options with as many YAML and JSON files and directories you want to add insideconfig/
- Allows for functionality to share this data in any language(s) your
resources/
orpublic/
folders might use
Why would I want this
Most all of my projects have extended configuration, everything from style guides to site copy, this allows stylus/css and coffeescript/javascript access to this data
Requirements
Installation
Require this package with Composer
composer require acidjazz/larjectus
Laravel
Once Composer has installed or updated your packages you need to register Larjectus with Laravel itself. Open up config/app.php and find the providers key, towards the end of the file, and add 'Larjectus\ServiceProvider', to the end:
'providers' => [ ... Larjectus\ServiceProvider::class, ],
Lumen
For usage with Lumen, add the service provider in bootstrap/app.php
.
$app->register(Larjectus\ServiceProvider::class);
configuration
gulpfile.js example(s)
Your gulp task is different from how Objectus works, here is an example of compiling a JSON version of your config for JavaScript access:
🚨 Note the secure
array where i remove any secure data, like DB passwords and AWS credentials. 🚨
exec = require('child_process').exec; objectify = function() { var config, secure; config = {}; secure = ['auth', 'database']; return exec('php artisan larjectus:config', function(error, result, stderr) { var dim, i, len, pubconfig; if (error) { notify(error); } this.config = JSON.parse(result); pubconfig = this.config; for (i = 0, len = secure.length; i < len; i++) { dim = secure[i]; delete pubconfig[dim]; } return fs.writeFileSync('public/js/config.js', "config="+JSON.stringify(pubconfig)+";", 'utf8'); }); }; objectify(); gulp.task('larjectus', objectify); gulp.task('watch', function() { gulp.watch('config/**/*', ['larjectus']); );
Here is an example of giving config access to stylus you would need the sample gulp task above :
stylus = require('gulp-stylus'); gulp.task('stylus', function() { return gulp.src('resources/stylus/main.styl') .pipe(stylus({ rawDefine: { config: config } }).on('error', notify.onError(function(error) { return { title: 'Stylus error: ' + error.name, message: error.message, sound: 'Pop' }; }))) .pipe(gulp.dest('public/css/')) .pipe(sync.stream()); }