Support the ongoing development of Laravel.io →
Configuration IOC Packages
Last updated 2 years ago.
0

Not that I'm aware of. What do you need it for?

Last updated 2 years ago.
0

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.

Last updated 2 years ago.
0

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.

Last updated 2 years ago.
0

Thanks, all the best :-)

Last updated 2 years ago.
0

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;
}

...
0

Sign in to participate in this thread!

Eventy

Your banner here too?

heera heera Joined 11 Feb 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.