Not that I'm aware of. What do you need it for?
Hey! Thanks man. I'm just thinking to build an admin (for backend) menu for a CMS, just trying to build a customiszable dynamic menu, depending on packages as modules (Gallery, Posts, Pages, Texonomies, terms etc) I want to build the menu. Thinking like WordPress. It's not for any project just built a sample application for a book (Laravel reference guide), so It came on my mind, but it could be useful for this kind of things. Thanks! BTW, what you are up to ? Don't see anything new on your blog.
Any thoughts on this to accomplish, scenario:
On the early stage of admin routing, build the admin menu depending on some modules/classes, don't know actually but hope you got it. Just, thinking like WordPress admin menu where a developer can also modify the menu items by adding his.her own or removing one depending on a role/permissions.
Ah yeah in that case you'd probably just need to keep your own running record of packages that can act as plugins for your CMS and either mark them as enabled/disabled in a DB or manifest of some sort.
As for the menu you'd probably want to have some kind of menu class that handles it all and each plugin would have a file or method in its service provider that is fired by your backend. It would be given an instance of the menu class that it can manipulate. Then you'd just need a view to render the menu that was generated by the menu class.
That's how I'd look at doing it. Something like that anyway. :P
Also, been busy with work! Planning on blogging again soon.
Why not just parse the composer.lock file? I have something similar going, to make a trait compatible with a couple different versions.
app/helpers.php:
if (!function_exists('get_package_version')) {
/**
* @param string $packageName
* @return string
*/
function get_package_version($packageName)
{
$file = get_include_path().'/../composer.lock';
$packages = json_decode(file_get_contents($file), true)['packages'];
foreach ($packages as $package) {
if ($package['name'] == $packageName) {
return $package['version'];
}
}
return null;
}
}
Then inside my trait:
$package = 'toin0u/geocoder-laravel';
$geolocationVersion = get_package_version($package);
if (!$geolocationVersion) {
throw new \Exception("Please install the '$package' package");
}
if (version_compare($geolocationVersion, '4.0', '<')) {
$this->_mockGeolocation();
return;
}
...
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community