php的laravel框架sae能支持吗
2个回答
2016-02-16 · 百度知道合伙人官方认证企业
育知同创教育
1【专注:Python+人工智能|Java大数据|HTML5培训】 2【免费提供名师直播课堂、公开课及视频教程】 3【地址:北京市昌平区三旗百汇物美大卖场2层,微信公众号:yuzhitc】
向TA提问
关注
展开全部
支持的。
改造本地项目使其支持 SAE 运行环境
接下来我会简要介绍本地项目的基本改造过程,从而使我们在不影响本地开发的情况下,做到本地开发和 SAE 线上运行环境的无痛切换。
1. 修改 app/config/app.php
<?php
$app = array(
'debug' => false,
'url' => 'http://www.dilicms.com',
'timezone' => 'PRC',
'locale' => 'zh-cn',
'key' => 'x1RYfs4ArTE12sz7879mdvse471epPAA',
'providers' => array(
'Illuminate\Foundation\Providers\ArtisanServiceProvider',
'Illuminate\Auth\AuthServiceProvider',
'Illuminate\Cache\CacheServiceProvider',
'Illuminate\Foundation\Providers\CommandCreatorServiceProvider',
'Illuminate\Session\CommandsServiceProvider',
'Illuminate\Filesystem\FilesystemServiceProvider',
'Illuminate\Foundation\Providers\ComposerServiceProvider',
'Illuminate\Routing\ControllerServiceProvider',
'Illuminate\Cookie\CookieServiceProvider',
'Illuminate\Database\DatabaseServiceProvider',
'Illuminate\Encryption\EncryptionServiceProvider',
'Illuminate\Filesystem\FilesystemServiceProvider',
'Illuminate\Hashing\HashServiceProvider',
'Illuminate\Html\HtmlServiceProvider',
'Illuminate\Foundation\Providers\KeyGeneratorServiceProvider',
'Illuminate\Log\LogServiceProvider',
'Illuminate\Mail\MailServiceProvider',
'Illuminate\Foundation\Providers\MaintenanceServiceProvider',
'Illuminate\Database\MigrationServiceProvider',
'Illuminate\Foundation\Providers\OptimizeServiceProvider',
'Illuminate\Pagination\PaginationServiceProvider',
'Illuminate\Foundation\Providers\PublisherServiceProvider',
'Illuminate\Queue\QueueServiceProvider',
'Illuminate\Redis\RedisServiceProvider',
'Illuminate\Auth\Reminders\ReminderServiceProvider',
'Illuminate\Foundation\Providers\RouteListServiceProvider',
'Illuminate\Database\SeedServiceProvider',
'Illuminate\Foundation\Providers\ServerServiceProvider',
'Illuminate\Session\SessionServiceProvider',
'Illuminate\Foundation\Providers\TinkerServiceProvider',
'Illuminate\Translation\TranslationServiceProvider',
'Illuminate\Validation\ValidationServiceProvider',
'Illuminate\View\ViewServiceProvider',
'Illuminate\Workbench\WorkbenchServiceProvider',
'Lavender\Cloud\Sina\Patcher\SaePatcherServiceProvider',
),
'manifest' => storage_path().'/meta',
'aliases' => array(
'App' => 'Illuminate\Support\Facades\App',
'Artisan' => 'Illuminate\Support\Facades\Artisan',
'Auth' => 'Illuminate\Support\Facades\Auth',
'Blade' => 'Illuminate\Support\Facades\Blade',
'Cache' => 'Illuminate\Support\Facades\Cache',
'ClassLoader' => 'Illuminate\Support\ClassLoader',
'Config' => 'Illuminate\Support\Facades\Config',
'Controller' => 'Illuminate\Routing\Controllers\Controller',
'Cookie' => 'Illuminate\Support\Facades\Cookie',
'Crypt' => 'Illuminate\Support\Facades\Crypt',
'DB' => 'Illuminate\Support\Facades\DB',
'Eloquent' => 'Illuminate\Database\Eloquent\Model',
'Event' => 'Illuminate\Support\Facades\Event',
'File' => 'Illuminate\Support\Facades\File',
'Form' => 'Illuminate\Support\Facades\Form',
'Hash' => 'Illuminate\Support\Facades\Hash',
'HTML' => 'Illuminate\Support\Facades\HTML',
'Input' => 'Illuminate\Support\Facades\Input',
'Lang' => 'Illuminate\Support\Facades\Lang',
'Log' => 'Illuminate\Support\Facades\Log',
'Mail' => 'Illuminate\Support\Facades\Mail',
'Paginator' => 'Illuminate\Support\Facades\Paginator',
'Password' => 'Illuminate\Support\Facades\Password',
'Queue' => 'Illuminate\Support\Facades\Queue',
'Redirect' => 'Illuminate\Support\Facades\Redirect',
'Redis' => 'Illuminate\Support\Facades\Redis',
'Request' => 'Illuminate\Support\Facades\Request',
'Response' => 'Illuminate\Support\Facades\Response',
'Route' => 'Illuminate\Support\Facades\Route',
'Schema' => 'Illuminate\Support\Facades\Schema',
'Seeder' => 'Illuminate\Database\Seeder',
'Session' => 'Illuminate\Support\Facades\Session',
'Str' => 'Illuminate\Support\Str',
'URL' => 'Illuminate\Support\Facades\URL',
'Validator' => 'Illuminate\Support\Facades\Validator',
'View' => 'Illuminate\Support\Facades\View',
),
);
$app['sae'] = false;
if (defined('SAE_ACCESSKEY') && (substr(SAE_ACCESSKEY, 0, 4 ) != 'kapp')) {
$removeProviders = array(
'Illuminate\Cache\CacheServiceProvider',
'Illuminate\View\ViewServiceProvider',
'Illuminate\Session\SessionServiceProvider',
);
foreach ($app['providers'] as $key => $provider) {
if (in_array($provider, $removeProviders)) {
unset($app['providers'][$key]);
}
}
$app['providers'] = array_merge($app['providers'], array(
'Lavender\Cloud\Sina\Cache\CacheServiceProvider',
'Lavender\Cloud\Sina\Storage\StorageServiceProvider',
'Lavender\Cloud\Sina\View\ViewServiceProvider',
'Lavender\Cloud\Sina\Session\SessionServiceProvider',
));
$app['aliases']['Storage'] = 'Lavender\Cloud\Sina\Storage\Storage';
$app['sae'] = true;
}
return $app;
以上代码主要作用:在判断程序运行在 SAE 运行环境下的时候,自动注入相应的类取代 Laravel 自带的类实现。
2. 修改 app/config/database.php
使用 SAE 数据库设置常量配置我们的数据库设置。
'mysql' => array(
'driver' => 'mysql',
'host' => SAE_MYSQL_HOST_M,
'database' => SAE_MYSQL_DB,
'username' => SAE_MYSQL_USER,
'password' => SAE_MYSQL_PASS,
'charset' => 'utf8',
'collation' => 'utf8_general_ci',
'prefix' => '',
),
3. 配置 app/config/cache.php 和 app/config/session.php
'driver' => 'memcache',
使用 SAE 提供的 memcache 驱动。
4. 配置本地开发环境
Laravel 支持自定义开发环境,一般本地开发就是 local 配置啦,这里可以在bootstrap/start.php 中设置。
然后我们在 app/config/local 文件夹下配置本地开发环境配置。
经过以上配置,我们搭建了本地开发和SAE运行环境的配置分离。
然后就是尽情开发啦~~~~~~~~~
上传代码到 SAE
改造本地项目使其支持 SAE 运行环境
接下来我会简要介绍本地项目的基本改造过程,从而使我们在不影响本地开发的情况下,做到本地开发和 SAE 线上运行环境的无痛切换。
1. 修改 app/config/app.php
<?php
$app = array(
'debug' => false,
'url' => 'http://www.dilicms.com',
'timezone' => 'PRC',
'locale' => 'zh-cn',
'key' => 'x1RYfs4ArTE12sz7879mdvse471epPAA',
'providers' => array(
'Illuminate\Foundation\Providers\ArtisanServiceProvider',
'Illuminate\Auth\AuthServiceProvider',
'Illuminate\Cache\CacheServiceProvider',
'Illuminate\Foundation\Providers\CommandCreatorServiceProvider',
'Illuminate\Session\CommandsServiceProvider',
'Illuminate\Filesystem\FilesystemServiceProvider',
'Illuminate\Foundation\Providers\ComposerServiceProvider',
'Illuminate\Routing\ControllerServiceProvider',
'Illuminate\Cookie\CookieServiceProvider',
'Illuminate\Database\DatabaseServiceProvider',
'Illuminate\Encryption\EncryptionServiceProvider',
'Illuminate\Filesystem\FilesystemServiceProvider',
'Illuminate\Hashing\HashServiceProvider',
'Illuminate\Html\HtmlServiceProvider',
'Illuminate\Foundation\Providers\KeyGeneratorServiceProvider',
'Illuminate\Log\LogServiceProvider',
'Illuminate\Mail\MailServiceProvider',
'Illuminate\Foundation\Providers\MaintenanceServiceProvider',
'Illuminate\Database\MigrationServiceProvider',
'Illuminate\Foundation\Providers\OptimizeServiceProvider',
'Illuminate\Pagination\PaginationServiceProvider',
'Illuminate\Foundation\Providers\PublisherServiceProvider',
'Illuminate\Queue\QueueServiceProvider',
'Illuminate\Redis\RedisServiceProvider',
'Illuminate\Auth\Reminders\ReminderServiceProvider',
'Illuminate\Foundation\Providers\RouteListServiceProvider',
'Illuminate\Database\SeedServiceProvider',
'Illuminate\Foundation\Providers\ServerServiceProvider',
'Illuminate\Session\SessionServiceProvider',
'Illuminate\Foundation\Providers\TinkerServiceProvider',
'Illuminate\Translation\TranslationServiceProvider',
'Illuminate\Validation\ValidationServiceProvider',
'Illuminate\View\ViewServiceProvider',
'Illuminate\Workbench\WorkbenchServiceProvider',
'Lavender\Cloud\Sina\Patcher\SaePatcherServiceProvider',
),
'manifest' => storage_path().'/meta',
'aliases' => array(
'App' => 'Illuminate\Support\Facades\App',
'Artisan' => 'Illuminate\Support\Facades\Artisan',
'Auth' => 'Illuminate\Support\Facades\Auth',
'Blade' => 'Illuminate\Support\Facades\Blade',
'Cache' => 'Illuminate\Support\Facades\Cache',
'ClassLoader' => 'Illuminate\Support\ClassLoader',
'Config' => 'Illuminate\Support\Facades\Config',
'Controller' => 'Illuminate\Routing\Controllers\Controller',
'Cookie' => 'Illuminate\Support\Facades\Cookie',
'Crypt' => 'Illuminate\Support\Facades\Crypt',
'DB' => 'Illuminate\Support\Facades\DB',
'Eloquent' => 'Illuminate\Database\Eloquent\Model',
'Event' => 'Illuminate\Support\Facades\Event',
'File' => 'Illuminate\Support\Facades\File',
'Form' => 'Illuminate\Support\Facades\Form',
'Hash' => 'Illuminate\Support\Facades\Hash',
'HTML' => 'Illuminate\Support\Facades\HTML',
'Input' => 'Illuminate\Support\Facades\Input',
'Lang' => 'Illuminate\Support\Facades\Lang',
'Log' => 'Illuminate\Support\Facades\Log',
'Mail' => 'Illuminate\Support\Facades\Mail',
'Paginator' => 'Illuminate\Support\Facades\Paginator',
'Password' => 'Illuminate\Support\Facades\Password',
'Queue' => 'Illuminate\Support\Facades\Queue',
'Redirect' => 'Illuminate\Support\Facades\Redirect',
'Redis' => 'Illuminate\Support\Facades\Redis',
'Request' => 'Illuminate\Support\Facades\Request',
'Response' => 'Illuminate\Support\Facades\Response',
'Route' => 'Illuminate\Support\Facades\Route',
'Schema' => 'Illuminate\Support\Facades\Schema',
'Seeder' => 'Illuminate\Database\Seeder',
'Session' => 'Illuminate\Support\Facades\Session',
'Str' => 'Illuminate\Support\Str',
'URL' => 'Illuminate\Support\Facades\URL',
'Validator' => 'Illuminate\Support\Facades\Validator',
'View' => 'Illuminate\Support\Facades\View',
),
);
$app['sae'] = false;
if (defined('SAE_ACCESSKEY') && (substr(SAE_ACCESSKEY, 0, 4 ) != 'kapp')) {
$removeProviders = array(
'Illuminate\Cache\CacheServiceProvider',
'Illuminate\View\ViewServiceProvider',
'Illuminate\Session\SessionServiceProvider',
);
foreach ($app['providers'] as $key => $provider) {
if (in_array($provider, $removeProviders)) {
unset($app['providers'][$key]);
}
}
$app['providers'] = array_merge($app['providers'], array(
'Lavender\Cloud\Sina\Cache\CacheServiceProvider',
'Lavender\Cloud\Sina\Storage\StorageServiceProvider',
'Lavender\Cloud\Sina\View\ViewServiceProvider',
'Lavender\Cloud\Sina\Session\SessionServiceProvider',
));
$app['aliases']['Storage'] = 'Lavender\Cloud\Sina\Storage\Storage';
$app['sae'] = true;
}
return $app;
以上代码主要作用:在判断程序运行在 SAE 运行环境下的时候,自动注入相应的类取代 Laravel 自带的类实现。
2. 修改 app/config/database.php
使用 SAE 数据库设置常量配置我们的数据库设置。
'mysql' => array(
'driver' => 'mysql',
'host' => SAE_MYSQL_HOST_M,
'database' => SAE_MYSQL_DB,
'username' => SAE_MYSQL_USER,
'password' => SAE_MYSQL_PASS,
'charset' => 'utf8',
'collation' => 'utf8_general_ci',
'prefix' => '',
),
3. 配置 app/config/cache.php 和 app/config/session.php
'driver' => 'memcache',
使用 SAE 提供的 memcache 驱动。
4. 配置本地开发环境
Laravel 支持自定义开发环境,一般本地开发就是 local 配置啦,这里可以在bootstrap/start.php 中设置。
然后我们在 app/config/local 文件夹下配置本地开发环境配置。
经过以上配置,我们搭建了本地开发和SAE运行环境的配置分离。
然后就是尽情开发啦~~~~~~~~~
上传代码到 SAE
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询