- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在评估将一个相当大的站点从经典 ASP 迁移到 PHP,当然我首先要查看所有潜在问题和速度障碍。 PHP 版本最初仍将在 IIS 下运行。
开发涉及本地 mySQL 服务器和一些本地域,例如localhost.website.com、localhost.cdn.website.com、localhost.api.website.com 等,但实时系统不使用它们中的任何一个,而是仅使用实时域等。
目前,在经典 ASP 中,系统通过使用仅存在于服务器上的信号量文件在“实时”和“开发”之间切换。它在 global.asa 中执行此操作,并根据文件的存在继续设置一组应用程序变量。
我对 PHP 不是特别熟悉,但环顾四周,它似乎运行“无共享”原则,因此没有“应用程序范围”的东西。
我想知道如何实现类似的环境,在该环境中无需更改即可在本地上传代码,并且系统会以有效的方式自动识别其所在的系统。
最佳答案
过去,我们使用这种技术取得了很大的成功:DevLevel.0
代表生产,DevLevel.1
代表分期,DevLevel.2
代表发展。我们有一个 PHP 全局包含检查 __FILE__
魔术常数,看看我们在什么地方,然后设置一个 DevLevel
相应地恒定。然后在不同的地方,我们会有:
if(DevLevel == 0)
run credit card in live mode;
else
run credit card in test mode;
/path/to/project/conf/example-local.php
/path/to/project/conf/local.php
/path/to/project/conf/.gitignore (contents: local.php)
example-local.php
.然后,任何时候开发人员或发布工程师 checkout 它的副本,他们只需要复制
example-local.php
至
local.php
并调整它。
<?
///////////////////////////////////////////////////////////////////////////////
define('App_Path', dirname(dirname(__FILE__)));
define('CORE_PATH', App_Path.'/Web/');
ini_set("max_execution_time", "0");
// For the purposes of including pear embedded in the application
set_include_path(App_Path . '/PHP/pear' . PATH_SEPARATOR . get_include_path() );
require_once(App_Path . "/AutoConf/Local.php");
///////////////////////////////////////////////////////////////////////////////
// Utility function to assert that a constant has been defined.
function DefinedOrDie($constant, $message)
{
if(! defined($constant))
die("Constant '$constant' not defined in site configuration. $message");
}
// Utility function to check if a constant is defined, and if not, define it.
function DefinedOrDefault($constant, $default)
{
if(! defined($constant))
define($constant, $default);
}
/////////////////////////////////////////////////////////////////////////////////
// These are the constants which MUST be defined in the AutoConf file
DefinedOrDie('DevLevel', "DevelopmentLevel. 0=Production, 1=Preview, 2=Devel.");
if(DevLevel !== 0 && DevLevel !== 1 && DevLevel !== 2)
die("DevLevel constant must be defined as one of [0, 1, 2].");
DefinedOrDie('DEFAULT_HOSTNAME', "Canonical hostname of the site. No trailing slash or leading protocol!");
DefinedOrDie('DB_HOST', "Database server hostname.");
DefinedOrDie('DB_NAME', "Database name.");
DefinedOrDie('DB_USER', "Database login username.");
DefinedOrDie('DB_PASS', "Database password.");
if(DevLevel > 0){
DefinedOrDie('Email_OnlySendIfMatch', "Preg regex email must match to be sent.");
DefinedOrDie('Email_OverrideAddress', "Email address to send all emails to.");
DefinedOrDie('Fax_OnlySendIfMatch', "Preg regex fax number must match to be sent.");
DefinedOrDie('Fax_OverrideNumber', "Fax number to send all faxes to.");
DefinedOrDie('Text_OnlySendIfMatch', "Preg regex text message must match to be sent.");
DefinedOrDie('Text_OverrideNumber', "Text number to send all texts to.");
DefinedOrDie('Phone_OnlySendIfMatch', "Preg regex phone number must match to be sent.");
DefinedOrDie('Phone_OverrideNumber', "Phone number to place all phone calls to.");
DefinedOrDefault('PROCESS_BILLING', false);
DefinedOrDefault('MEMCACHE_ENABLED', false);
}else{
DefinedOrDefault('PROCESS_BILLING', true);
DefinedOrDefault('MEMCACHE_ENABLED', true);
}
///////////////////////////////////////////////////////////////////////////////
// These are the constants which MAY be defined in the AutoConf file
// Default settings for live site
if(DevLevel == 0)
{
define('DEVEL', false);
define('DEVEL_DEBUG', false);
error_reporting (E_RECOVERABLE_ERROR | E_ERROR | E_PARSE);
ini_set("display_errors", false);
}
// Default settings for preview site
elseif(DevLevel == 1)
{
define('DEVEL', true);
define('DEVEL_DEBUG', false);
error_reporting (E_ALL & ~E_NOTICE & ~E_STRICT & ~E_DEPRECATED);
ini_set("display_errors", true);
}
// Default settings for development and other sites
else
{
// TODO: remove E_DEPRECATED, and take care of all warnings
define('DEVEL', true);
define('DEVEL_DEBUG', false);
error_reporting (E_ALL & ~E_NOTICE & ~E_STRICT & ~E_DEPRECATED);
ini_set("display_errors", true);
}
// Memcache settings are required, here are defaults
DefinedOrDefault('MEMCACHE_HOST', 'localhost');
DefinedOrDefault('MEMCACHE_PORT', '11211');
<?php
define('DevLevel', 1);
define('DB_HOST', 'localhost');
define('DB_NAME', '*******');
define('DB_USER', '*******');
define('DB_PASS', '*******');
define('DEFAULT_HOSTNAME', '***********');
define('MEMCACHE_SESSION_HOST', 'localhost');
//define users who will be notified when different alerts are sent by the system. Separate users with a |
define('ALERT_LEVEL_NOTICE_SMS', '122342342319');
define('ALERT_LEVEL_NOTICE_EMAIL', 'j3@example.com');
define('PROCESS_BILLING', false);
define('Email_OnlySendIfMatch', '/(appcove.com|example.com)$/');
define('Email_OverrideAddress', false);
define('FAXES_LIVE', true); //false to use phaxio's test keys (no faxes are sent)
function HN_LiveToDev($host){
return str_replace('.', '--', $host).'.e1.example.net';
}
function HN_DevToLive($host){
$count = 0;
$host = str_replace('.e1.example.net', '', $host, $count);
if($count > 0){
return str_replace('--', '.', $host);
}else{
die('URL does not look like a dev URL. Could not translate DevToLive.');
}
}
关于php - 从经典 ASP 迁移到 PHP - 本地资源与实时资源,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14285798/
我最近开始从事一个 Sails 项目。它目前在迁移表下具有以下格式的迁移。 20160826122004-create_users_table.js 'use strict'; module.expo
当我尝试迁移时 doctrine:migrations:migrate ,我收到此异常:“元数据存储不是最新的,请运行 sync-metadata-storage 命令来解决此问题。”。这仅在尝试在生
我在 ec2 linux 7 上有一个 MarkLogic 服务器。我想将它迁移到 linux 6。我将 ebs 移动到新的 linux 6 并将其安装在 /var/opt/MarkLogic . 我
我对 OpenID 很好奇。虽然我同意统一凭证的想法很棒,但我有一些保留意见。什么是防止 OpenID 提供商发疯并持有他们拥有的 OpenID 帐户直到您支付 n 美元?如果我决定不喜欢这个提供商,
使用 SQL 很容易做到这一点,但我需要编写一个我不熟悉的 Knex 迁移脚本。以下代码在 order 表中行的末尾添加了 order_id 列。我想在 id 之后添加 order_id。我该怎么做?
使用 SQL 很容易做到这一点,但我需要编写一个我不熟悉的 Knex 迁移脚本。以下代码在 order 表中行的末尾添加了 order_id 列。我想在 id 之后添加 order_id。我该怎么做?
我想通过在 Yii2 中的迁移添加一个新列,使用以下代码: public function up() { $this->addColumn('news', 'priority', $this-
我正在尝试在 SQLDelight 的表中添加更多列。我做了一个迁移文件 1.sqm .在迁移文件中,它给出了找不到表的错误。 我的 build.gradle.kts: sqldelight {
我有一个与 Flyway DB 迁移相关的问题。通常如何管理处理相同 DB 模式的多个项目(微服务)。每个项目中的 Flyway 迁移脚本如果被其他项目修改,则不允许启动。他们是否有任何文档或最佳实践
我是 Laravel 的新手。我做了一份待办事项申请作为一项学校作业。我们必须使用迁移来创建我们的数据库。 我使用迁移创建了 2 个表。我的问题是:如果你第一次在你的电脑上运行这个项目,有没有办法自动
我正在尝试在 Laravel 中创建外键,但是当我使用 artisan 迁移表时,出现以下错误: [Illuminate\Database\QueryException] SQLSTATE[HY000
我从 Django 1.7 升级到 Django 1.9。我有多次迁移。升级后我无法再创建新的数据库。 问题是“django manage.py migrate”运行检查。检查导入应用程序 URL。这
我在创建数据迁移方面遇到了困难。我的应用程序使用两个数据库。我在 settings.py 中配置了数据库,并创建了一个像 Django docs 中一样的路由器. # settings.py DB_H
我有一个像这样的sql结构: CREATE TABLE resources ( id SERIAL PRIMARY KEY, title TEXT NOT NULL, created_at
我正在尝试使用模式构建器向表添加枚举选项(不丢失当前数据集)。 我真正能够找到的关于列更改的唯一信息是 http://www.flipflops.org/2013/05/25/modify-an-ex
我尝试转移到一些 CMake 程序中,并且有一个从 xml 生成头文件的函数。 生成文件.am adaptor_glue.hpp: dbus_introspect.xml $(DBUSXX_X
我想将文件移至我的 iOS 应用程序的 CoreData 存储 ../Library/Application Support/MyApp/ 至 ../Documents/Stores/ 我可以使用 N
有没有人对数据迁移进出 NetSuite 有丰富的经验?我必须将 DB2 表导出到 MySQL,处理数据,然后导出到一个 CSV 文件中。然后获取帐户的 CSV 文件并再次操作数据以使帐户从我们的旧系
我正在尝试在 Django 上建立一个博客。我已经走到了创建模型的地步。他们在这里: from django.db import models import uuid class Users(mode
我最近使用 bluehost 上的 AutoSSL 工具将网站迁移到 HTTPS。我在内容中看到一些失真,例如缺少背景颜色、表格位移、缺少_logos 等。 有谁知道 HTTPS 迁移效果如何影响样式
我是一名优秀的程序员,十分优秀!