I started to develop a backoffice in laravel (www.example.com/admin) and take use of MVC structure that is offered.
Now it is needed to develop online store in the same domain (www.example.com). What is the best approach to separate the two modules?
For instance one route file/controller folder for backoffice and other for the front site?
Best
Just like api and web routes are split in two separate files in Laravel 5.3, you could split admin and non-admin routes further in two separate files, passing different Controller prefixes (namespaces) to each one and adding an authentication middleware for admin routes. Look into your RouteServerProvider.php.
That's more than enough for a small-to-medium website IMHO.
Related
I'm using CodeIgniter, and I need to create an admin side (back-end) and a client side (front-end). I followed this tutorial.
Controllers, models folders are in both admin folder and front folder, but I wonder if I do it in this way, how am I going to share commonly used functions in models?
Do you have any suggestions?
My situation:
Using Laravel 5.1, I want to use it's built in ACL features.
Challenge:
My website has a Admin and a Client side to it. On top of that, the database structure for each is very different and the Control Panel for Admin and Client is very different.
How do I go about implementing ACL with this?
Note - I have subfolders for each part of the website (one folder for client side, one folder for admin, one folder for front-end pages).
Is this even possible to build using Laravel's built-in ACL system? or should I make my own in my situation? Thank you.
I have an existing Zend Framework 2 project. Now I've been experimenting and considering rebuilding the front end to be entirely AngularJS, as opposed to the now with Zend Framework 2 MvC coupled layouts and views. But for that reason, the models and controller with their respective routes exist and they use services that have a lot of business logic.
If I were to add an API to this existing project through Apigility, say, for external third parties to be able to access account information, how am I supposed to do that without interfering with my current controller routes?
Apigility Admin UI automaticly creates routes appending the base url (www.domain.com/[api url]). This does not directly conflict when I have an AccountController with /account routes and an API route that uses /accounts/[:accountId] but mistakes are bound to happen.
I should use a url like api.domain.com, however Apigility Admin UI adds the routes automaticly and has, as far as I have seen, no option to create a subdomain route through subdomain 'api'. Of course I could modify the automaticly generated routes every time I make changes through Admin UI but that seems like a hassle and prone to error.
While spreading my question around for an answer, someone on the #apigility IRC channel was friendly enough to give me an answer.
I was overthinking this, as dualmon mentioned in the comments. I had thought Apigilty Admin UI was a tool for managing the whole API. nuxwin^ on IRC told me that while Apigility Admin UI does automate routes for you which can be configured with a base url, it's still only meant for development time. It would mean if I were to route my subdomain to a module I could do that after developing the API.
Simple solution, I just had been overthinking that tool demanded me to follow a certain path.
I'm studying the Laravel 3, 1 week ago, but didn't understand everything about the routes.
My main question is: how to create administrative routes?
In the video lessons from Jeffrey Way (Tuts Premium), I could understand two things about it:
Nested Controllers (/application/controllers/admin/user.php)
Bundles (/bundles/user.php) - He did not say much about it.
Anyway, I noticed 2 things (obvious):
On both sides, I can have a route / admin / whatever.
But what the correct way?
I'm really very confused.
Laravel bundles are for developing modular code that you can reuse from application to application in Laravel. The Bundle itself is very much the same as the 'application' directory you have as standard in a Laravel install, allowing you to create modular sub applications within your project. I highly recommend you avoid bundles for the moment entirely and focus on learning the core functionality of Laravel.
For your needs, place your routes within your routes.php file within the application directory and nest them to your hearts content. This will serve your purposes fine. If you're not building/using bundles, you don't need to use bundle routes.
When you're comfortable with Laravels routing and you've built one or two apps you may well have an idea for a bundle that will help you develop your apps faster in the future. This is the time to start learning about bundle routing as it's the only way to link your application logic with your bundle and provide it with a URL schema.
Hope that helps.
Neither way is really right or wrong, the beauty of Laravel is that there are so many ways to achieve the same thing so it's up to the developer to choose what works for them.
Personally I started by using nested controllers as they're much easier to get up and running. I would however recommend making the move to bundles. If you plan on sticking with Laravel (and you should) then it would make sense to build a bundle that includes the auth and components you use in each project already setup. That way you just need install the bundle and you're good to go.
Kohana, due to cascading file system and modules, allows to share code in common projects, that contains controllers, views and models directories. How can I do it in codeigniter? I want to create sites, that will share some code (admin area views, some models). That is easy in Kohana, we just have to add another directory for Kohana::find_file().
I think this is a duplication of:
Codeigniter Shared Resources - Opinions Wanted
And
How do I load a view from a specific (shared) path in CodeIgniter?
I'm more experienced in Kohana than CI but if I'm right there is a HMVC module in CodeIgniter. You could see if you are able to request a external page like you can with the HMVC of kohana.
If I may ask. why do you use codeigniter when you know kohana does the job better?