CakePHP一核,一应用,一数据库,多个域和多个主题 [英] CakePHP One Core, One App, One Database, Multiple Domains & Multiple Themes

查看:56
本文介绍了CakePHP一核,一应用,一数据库,多个域和多个主题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是CakePHP世界的新成员,只创建了/遵循了博客教程,并向用户扩展了它。我一直在阅读2.0本书,以更加熟悉该框架。

I am a new addition to the world of CakePHP, and have only created / followed the blog tutorial, and extended it with users. I have been reading the 2.0 book to become more familiar with the framework.

在我致力于使用CakePHP之前,我有两个问题。

Before I commit to moving to CakePHP, I have a couple of questions.

当前,我开发了一个多域/多主题CMS系统,它是过程PHP。这样,我就可以在具有多个域和主题的单个数据库上创建单个系统。

Currently, I develop a multi domain / multi theme CMS system which is procedural PHP. By doing this I have been able to create a single system on a single database with multiple domains and themes.

我使用 $ _ SERVER [' SERVER_NAME'] ,然后在品牌表中查找它,然后返回brand_id和主题目录。然后,我所有的SQL查询都以和brand_id = X作为后缀。

I take the $_SERVER['SERVER_NAME'] and look it up in a table of "brands" and then return a brand_id and theme directory. I then suffix all my SQL queries with "and brand_id = X".

由于当前平台的规模和复杂性已不堪重负,我希望转到Cake。

I am looking to move over to Cake as the current platform has become overwhelming in size and complexity.

所以总之...

我可以用一个内核,一个应用程序和一个数据库创建一个应用程序吗

Can I create an application with One Core, One App, One Database that can serve Multiple Domains and Themes?

我会使用 $ _ SERVER ['SERVER_NAME'] 查找可以同时服务多个域和主题的内容吗?域并返回brand_id和主题?

Would I use $_SERVER['SERVER_NAME'] to look up the domain and return back a brand_id and theme?

我真的不想要多个数据库,好像我们有大量的客户在所有数据库中进行更改一样证明非常耗时。

I don't really want to have multiple databases, as if we had a large number of customers making changes across all databases could prove time consuming.

我当然不想拥有多个控制器和多个模型,但是在某些情况下,如果客户有特定要求,我们希望获得定制视图

I certainly don't want to have multiple controllers and multiple models, but in some cases we would want a bespoke view if a customer had a specific requirement.

关于基本配置的任何指导都可以帮助我入门。每个模型都会属于一个品牌吗?您将如何服务一个品牌?

Any guidance on a basic configuration to get me started would be great. Would each Model "belong to" a "brand"? How would you "serve" up a brand?

Name: Brand1 Domain: www.brand1.com ThemeDir: Brand1
Name: Brand2 Domain: www.brand2.com ThemeDir: Brand2


推荐答案

我在使用通配符子域时也遇到类似情况。我是通过做一些事情来实现这一点的。

I have a similar situation in which I am using wildcard subdomains. I accomplished this by doing a combination of things.


  1. 在我的引导文件中,我正在子域中读取并为其分配值到cakePHP缓存。以我为例:

  1. In my bootstrap file I am reading in my subdomain and assigning it a value to the cakePHP cache. In my case I am calling:

Configure :: write('SubdomainHTTP',$ myvalue);

这将是您的域名。


  1. 我在我的route.php文件中加载了名为subdomainRoute.php的文件名。此文件检查以确保在我的情况下,路由或子域在数据库中存在。最后,使用Configure :: write像步骤1一样写子域名和主题名称。

  1. I am loading in my routes.php file a filename called subdomainRoute.php. This file checks to make sure that the route or subdomain in my case exists in the database. It concludes by writing the subdomain name and theme name using Configure::write like step 1.

App :: uses('SubdomainRoute',' Routes');

我在这里将它们粘合在一起,在AppController.php中,我阅读了在第2步中编写的信息。具体的主题名称,并使用以下内容进行设置:

I glue it all together here, in my AppController.php I read the information I write in step 2. Specifically the theme name and set it using:

$ this-> theme = $ yourtheme;

这应该允许您使用不同的域名主题。鉴于您将不得不拥有一个数据库来保存域名列表和主题名称。

This should allow you to have different domain name themes. Given you will have to have a database to hold a list of domain names and there theme names.

这篇关于CakePHP一核,一应用,一数据库,多个域和多个主题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆