Vra

If I'm not mistaking, Laravel's Bundles should be similar to Codeigniter's Hierarchical MVC triads. I have a project built in CI and I want to migrate it to Laravel, so I'm trying to match some functionality. In CI all there was to it was to install HMVC extension, create an appropriate folder structure and you can already access your newly created controllers. In Laravel though, after you create a bundle, you need to register it in application/bundles.php by adding

return array('newbundle'),

Is there a way for me to automatically register all the (valid) bundles that exist in my bundles' directory? As in, without having to explicitly register every new bundle. In other words, I want to make bundles a bit more dynamic, so that I can just copy one bundle, paste it in another project and start using it right away.

As a side question, does anyone have an idea of the 'proper' way to achieve with Laravel's bundles what Wordpress does with its plugins: show a list of all the bundles installed in the bundles' dir, but only activate (register) the selected ones?

Was dit nuttig?

Oplossing

I don't understand why no one have given you the actual answer. By now, you might have figured it out how to achieve auto loading the bundles on the go, if not, please take a look at the following bundle.

http://bundles.laravel.com/bundle/autobundle

To your second question, you would need to develop a custom app/bundle to manage it the way wordpress is doing with plugins. I can only give you the idea and the development part is all yours.

Keep a database table (example bundles) and have a custom bundle or route/controller to manage adding/removing bundles, including uploading new bundles as zip and extracting it to the bundles folder while registering the bundle details in the db table. whenever you want to activate the plugin, make the activate field true and have the a custom bundle start method in the main start.php of the application directory which can be a function to fetch all the names of the activated bundles and have them loaded to the registry. If you want to use this approach, you may avoid using the autobundle as it will actually load everything in the bundle directory.

Gelisensieer onder: CC-BY-SA met toeskrywing
Nie verbonde aan StackOverflow
scroll top