Hello all,
TL;DR
How can i create a 'module manager' in laravel where composer package can plug into and where i can get back the list of the plugged in packages ?
The problem
I build an APP that can perform somme image transformation on uploaded images. This transformations are provided by composer paskages, and are groupped in different use: (color, transformation, cut and resize, etc... )
I would like to know the list of 'image modifier' package and in which usecase (color, transformation, cut and resize, etc... ).
I don't like to put this in the composer.json., i would like to do this in a system like the package say: Hey laravel, i am 'Awesome Effects 3000' and i can do 'solarize' and 'destructurate' in 'colors'
A little like this in php:
class awesomePackage3000 extends imagePackageManager
{
function registerImagePackage() {
$app->imagePackages[] = [
'name' => 'Awesome Effect 3000',
'identifier' => 'awesome_effect_3000',
'version' => '4.2',
'can_do' => ['solarize', 'destructurate'],
'use_case' => 'colors'
];
}
}
I can have an artisan command for updating the list of package that are modules like this:
artisan modules:refresh
Where it update the 'modules' table in the db for example.
And doing somewhere else in laravel (in the imageModulesController for example) :
if (!checkModuleAvaliability('awesome_effect_3000'){
abort(403, 'Module do not exist or is not activated');
}
The questions
- I don't know where to declare the
imagePackageManager class ...
- ... and how it will working/live inside laravel.
- That's a "service provider" in sens of laravel?
Many thanks!!
Seby