Hailwood Hailwood - 1 month ago 15
PHP Question

Admin panel in Laravel?

I am looking at switching from Code Igniter to Laravel.

We deploy a large amount of sites, using our custom admin panel.

This is setup as two installations of Code Igniter,
You basically have (simplified, we actually use HMVC on both the main site and the admin panel, but this gets the point across)

index.php
assets
system
application
config
controllers
models
views
admin
index.php
assets
application
config
controllers
models
views


And the admin install is setup to load the config files (e.g.
database.php
) from the main site via includes.

All our models for the main site use the models from the admin panel via include and then extend them, allowing us to have the functions that are specific to the main site in the main site only.

This has worked quite well for us, but now we are switching to Laravel we are wondering if there is a better way of doing this, We use the admin panel to manage several "modules" such as a blog, shopping cart, property manager, which are all drop ins.

Essentially we want to be able to:


  • keep the separation of the main site from the admin panel clear so we can use the admin panel on any of our sites.

  • Be able to still drop in bundles (e.g. a blog bundle).

  • Idealistically we would like to have a shared bundles folder between the admin panel and the main site with three folders.
    admin
    /
    main
    /
    shared
    so a bundle is self contained.



What would the best way of implementing this be in laravel?

Answer

You may have already pondered this, but I think it would be best to use an admin bundle, considering that bundles are all part of the core system. It's good for SoC and for simplicity (ease of use).

The admin panel could then find all bundles (except itself, of course) to read and write configuration entries, such as those of a blog bundle.

An alternative would be to place the admin panel into your main application, by routing specific commands to various admin controllers (don't forget that you can put controllers into sub-folders). For example, you could route, using routes.php, admin/pages/edit/152 to the pages.php controller in application/controllers/admin/. You could even manage your various bundles/snap-ins using this approach, by means of scanning the bundles directory, as mentioned before.

Comments