This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.
Potentially yes, Plugins are like bundles (Service Providers) with their own vendor folder. So you could include a composer.json file in the plugin directory that requires a Laravel package, then register that package in your Plugin.php registration file.
Last updated
Thanks Sam I will try that, but don't be surprised if I come back with more questions :( I'm still wrapping my head around using Laravel in general, as have always been one who leant more towards a CMS with a GUI & backend, rather than using a framework from scratch - sorry :)
Great stuff Sam, worked like a charm - took a bit of messing around with folder structure & folder names etc to register the plugin, but other than that everything seemed to work fine :)
For testing October, Ive created a small dropbox plugin. Part of the plugin is a composer.json which fetch the dropbox sdk. How would I go about keeping the plugin vendor/dropbox/composer up to date without having to do a 'composer update' on all plugins requiring a service provider?
I've just been using bundles/packages like normal. I put them in my main composer.json and use them in my models/controllers. You probably have to use
them at the top of your controller... or put a forward slash infront.
Examples:
- I can add
use Carbon\Carbon;
at the top of the .php file then I can use carbon like normal:$date = Carbon::now()->addSeconds(2);
- I can I am using laravel excel (http://www.maatwebsite.nl/laravel-excel/docs) in in my main composer.json and use it just by adding a slash:
$file = \Excel::load($path)->get();
That's way smarter than having 3-4 compose.json - thanks. A question though, if I add them to the service provider list in October, will they get overwritten if October updates?
Add them where you would normally add them for laravel: app/config/app.php. For example, I added anvard 'Atticmedia\Anvard\AnvardServiceProvider',
here:
/*
|--------------------------------------------------------------------------
| Autoloaded Service Providers
|--------------------------------------------------------------------------
|
| The service providers listed here will be automatically loaded on the
| request to your application. Feel free to add your own services to
| this array to grant expanded functionality to your applications.
|
*/
'providers' => array_merge(include(base_path().'/modules/system/providers.php'), array(
// 'Illuminate\Html\HtmlServiceProvider', // Example
'System\ServiceProvider',
'Atticmedia\Anvard\AnvardServiceProvider',
)),
Stuff in app/ won't get overwritten.
Last updated
I'm having major issues getting laravel packages to install into my OctoberCMS project. Can anyone give me some guidance here? :(
tallcoder1340 You have to be way more specific about your problems. Just writing that you have major problems will get you no help at all.
tallcoder1340 If you install october through web installer rather than using composer then you have some missing files, such composer.json in root folder and .gitignore files.
Just copy them to your project from octobercms repo. Then add library you wanted and do composer update. After that you should add service provider and optionally alias.
If you develop earlier on laravel, then you gotta understand.
For future reference I've written a post about how to deal with Laravel packages within your October plugins in a clean and easy to use way. You can view the post here https://luketowers.ca/blog/how-to-use-laravel-packages-in-october-cms-plugins/
1-13 of 13