Laravel 中的管理面板?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/13983543/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 07:27:11  来源:igfitidea点击:

Admin panel in Laravel?

phplaravel

提问by Hailwood

I am looking at switching from Code Igniter to Laravel.

我正在考虑从 Code Igniter 切换到 Laravel。

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

我们使用我们的自定义管理面板部署了大量站点。

This is setup as two installations of Code Igniter,

这是设置为两个 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)

你基本上有(简化,我们实际上在主站点和管理面板上都使用 HMVC,但这得到了重点)

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.

并且管理员安装设置为database.php通过包含从主站点加载配置文件(例如)。

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.

我们所有的主站点模型都通过 include 使用管理面板中的模型,然后扩展它们,允许我们仅在主站点中拥有特定于主站点的功能。

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.

这对我们来说效果很好,但是现在我们正在切换到 Laravel,我们想知道是否有更好的方法来做到这一点,我们使用管理面板来管理几个“模块”,例如博客、购物车、物业管理器、这些都是插件。

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/sharedso a bundle is self contained.
  • 保持主站点与管理面板的清晰分离,以便我们可以在我们的任何站点上使用管理面板。
  • 仍然能够放入捆绑包(例如博客捆绑包)。
  • 理想情况下,我们希望在管理面板和主站点之间有一个共享的 bundles 文件夹,其中包含三个文件夹。admin/ main/shared所以束是自包含的。

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

在laravel中实现这一点的最佳方式是什么?

采纳答案by Mike Rockétt

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).

您可能已经考虑过这一点,但我认为最好使用管理包,因为包都是核心系统的一部分。这对 SoC 和简单性(易用性)都有好处。

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/152to the pages.phpcontroller 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.

另一种方法是将管理面板放置到您的主应用程序中,通过将特定命令路由到各种管理控制器(不要忘记您可以将控制器放入子文件夹)。例如,你可以路线,使用routes.phpadmin/pages/edit/152pages.php控制器中application/controllers/admin/。如前所述,您甚至可以使用这种方法通过扫描 bundles 目录来管理各种 bundles/snap-ins。

回答by Web Developer in Pune

I was also switching from CI to Laravel and found that basic Admin Panel are there in Laravel but not a proper solutions to Handle Data while generating CRUD's

我也从 CI 切换到 Laravel,发现 Laravel 中有基本的管理面板,但不是在生成 CRUD 时处理数据的正确解决方案

Check LaraAdmin is a Open source Laravel Admin Panel / CMS which can be used as Admin Backend, Data Management Tool or CRM boilerplate for Laravel with features like CRUD Generation, Module Manager, Media, Menus, Backups and much more.

Check LaraAdmin 是一个开源的 Laravel 管理面板/CMS,可用作 Laravel 的管理后端、数据管理工具或 CRM 样板,具有 CRUD 生成、模块管理器、媒体、菜单、备份等功能。

Documentation: http://laraadmin.com/docs/1.0

文档:http: //laraadmin.com/docs/1.0

Source Code: https://github.com/dwijitsolutions/laraadmin

源代码:https: //github.com/dwijitsolutions/laraadmin

回答by dasper

Is there a way you can change your Apache configuration so each site is a virtual host one directory up from Laravel? This way each site would be its own "html" directory and you would not really need to change anything in Laravel; the line in index.php will do all the heavy lifting for you:

有没有一种方法可以更改 Apache 配置,使每个站点都是 Laravel 上一个目录的虚拟主机?这样,每个站点都将成为它自己的“html”目录,您实际上不需要在 Laravel 中更改任何内容;index.php 中的行将为您完成所有繁重的工作:

require '../paths.php';

This is assuming all your sites run on the same machine or cluster so your system would look like this

这是假设您的所有站点都在同一台机器或集群上运行,因此您的系统看起来像这样

assets
system
application
  config
  controllers
    admin
    site1
    site2
  models
    admin
    site1
    site2
  views    
    admin
    site1
    site2
html_site1
html_site2

however if you just want to have the admin panel be its own application, you could just copy the contents of html into the admin directory, alter the mod_rewrite or .htaccess for that dir and then change

但是,如果您只想让管理面板成为它自己的应用程序,您可以将 html 的内容复制到管理目录中,更改该目录的 mod_rewrite 或 .htaccess,然后更改

require '../paths.php';

to

require 'path/to/admin/paths.php';

and it will use a completly different laravel application.

它将使用完全不同的 Laravel 应用程序。

回答by dataphile

You can use Laravella (a CMS, CRUD package for laravel)

你可以使用 Laravella(一个 CMS,laravel 的 CRUD 包)

https://github.com/laravella/laravella/releases

https://github.com/laravella/laravella/releases

Whether you use Laravella or not, create a package for each site which overrides the main site's classes. That way you can keep each site is in its own source control repository.

无论您是否使用 Laravella,都要为每个站点创建一个包来覆盖主站点的类。通过这种方式,您可以将每个站点保留在其自己的源代码控制存储库中。