简体   繁体   English

如何为PHP中的多客户共享代码迁移到utf8

[英]how to migrate to utf8 for a multi-customer shared codeBase in PHP

in our company we use a proprietary CMS, this CMS is in use for almoust a thousand websites and is aged of approximatively 15 years. 在我们公司中,我们使用专有的CMS,该CMS已用于近一千个网站,并且其使用期限大约为15年。 (it has evolved but is very features rich) (它已经进化,但是功能非常丰富)

until now whe have always used iso-8859-1 as charset, but whe have the nescessity to use utf-8 for one project. 到目前为止,一直使用iso-8859-1作为字符集,但是有必要在一个项目中使用utf-8。

there are my questions : 我的问题是:

  1. do you think that this way to do is good (maintaining one SVN version, automatic conversion to the utf8 search/replace the problematic php functions and do some magic there). 您是否认为这种方法好(维护一个SVN版本,自动转换为utf8即可搜索/替换有问题的php函数,并在那里做一些魔术)。
  2. Have you done this kind of evolution before, what is hasardous regarding to you? 您以前做过这种进化,对您来说有什么麻烦呢?

TLDR infos : TLDR信息:

  • the core of our CMS is centralised (SVN) and deployed (rsynch) on a specific path on each of our servers, this path is in the include path of each websites. CMS的核心是集中(SVN)和部署(rsynch)在我们每台服务器上的特定路径上,该路径在每个网站的包含路径中。
  • The databases are different for each projects (but same structure for the core tables). 每个项目的数据库不同(但核心表的结构相同)。
  • each website use a document_root holding website's specifics files (media, js, specific PHP code) 每个网站都使用document_root来保存网站的特定文件(媒体,js,特定的PHP代码)

in this configuration, we cannot migrate every website on a single time (ie : because there is local code). 在这种配置下,我们无法一次迁移每个网站(即::因为存在本地代码)。 So I want to make two version of our core : one in iso-8859-1 and the other in utf8. 因此,我想制作两个内核版本:一个在iso-8859-1中,另一个在utf8中。 From now I think that I'm going to develop a script on our deployement system, this script, will create a copy utf8 encoded of our core before the rsynch-ing. 从现在开始,我认为我将在部署系统上开发一个脚本,该脚本将在rsynching之前创建一个对我们核心进行编码的utf8副本。

My concern is for example about all the "mb_ " stuff in PHP that won't be called, so i'll have to search/replace every php native fucntion to replace it by a custome one that will use the "mb_ " version if nescessary (furthermore, the overloding of those functions must be in the php.ini file, it cannot be defined in the .htaccess of a particulare website ( source )) 例如,我担心的是PHP中所有“ mb_ ”内容都不会被调用,因此我将不得不搜索/替换每个php本机功能,以将其替换为将使用“ mb_ ”版本的自定义脚本。不必要的(此外,这些功能的覆盖必须在php.ini文件中,无法在特定网站的.htaccess中定义它( ))

PS : sorry for my poor english, it's not my native language :( PS:对不起,我的英语不好,那不是我的母语:(

So here is how I handled it : 所以这是我的处理方式:

  • each server is either iso-8859-1 or utf-8, and have dedicated conf (ie : mbstring.func_overload) 每个服务器都是iso-8859-1或utf-8,并具有专用的conf(即:mbstring.func_overload)
  • before each deployement a script create a copy of the iso version and convert it to utf8 在每次部署之前,脚本会创建iso版本的副本并将其转换为utf8
  • each server get either utf-8 or iso-8859-1 source code 每个服务器获取utf-8或iso-8859-1源代码

for each individual CMS, a convertion tool exist, it convert filesystem, database charset/collation, configuration (ie : connect to mysql with utf8), .... 对于每个单独的CMS,都有一个转换工具,可以转换文件系统,数据库字符集/排序规则,配置(即:使用utf8连接到mysql),...。

for non compatible functions such as utf8_encode, I search/replaced it with a function who is in charge to not call the function if the server is utf8 对于不兼容的功能(例如utf8_encode),我将其搜索/替换为负责的功能(如果服务器为utf8,则该功能不调用该功能)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM