承接 shpasser/gae-support-lumen 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

shpasser/gae-support-lumen

Composer 安装命令:

composer require shpasser/gae-support-lumen

包简介

Google App Engine Support for Lumen apps.

README 文档

README

Latest Stable Version Total Downloads Latest Unstable Version License

Google App Engine(GAE) Support package for Lumen.

Currently supported features:

  • Generation of general configuration files,
  • Mail service provider,
  • Queue service provider,
  • Database connection,
  • Filesystem.

For Laravel 5 see https://github.com/shpasser/GaeSupportL5.

Installation

Pull in 'shpasser/gae-support-lumen' and 'illuminate/mail' packages via Composer.

"require": {
    "shpasser/gae-support-lumen": "~1.0",
    "illuminate/mail": "~5.0"
}

Within bootstrap/app.php:

  • Uncomment the following line in order to use the Facades
$app->withFacades();
  • Include the service provider
$app->register(Shpasser\GaeSupportLumen\GaeSupportServiceProvider::class);

Usage

Generate the GAE related files / entries.

php artisan gae:setup --config --bucket="your-bucket-id" --db-socket="cloud-sql-instance-socket-connection-string" --db-name="cloud-sql-database-name" --db-host="cloud-sql-instance-ipv4-address" your-app-id

The default GCS bucket is configured unless a custom bucket id is defined using the --bucket option.

When --db-name option is defined at least one of --db-socket or --db-host should be defined also.

Mail

The mail driver configuration can be found in config/mail.php and .env.production, these configuration files are modified / generated by the artisan command. There is no need in any kind of custom configuration. All the outgoing mail messages are sent with sender address of an administrator of the application, i.e. admin@your-app-id.appspotmail.com. The sender, to, cc, bcc, replyTo, subject, body and attachment parts of email message are supported.

Queues

The modified queue configuration file config/queue.php should contain:

return array(

	...

	/*
	|--------------------------------------------------------------------------
	| GAE Queue Connection
	|--------------------------------------------------------------------------
	|
	*/

	'connections' => array(

		'gae' => array(
			'driver'	=> 'gae',
			'queue'		=> 'default',
			'url'		=> '/tasks',
			'encrypt'	=> true,
		),

		...

	),

);

The 'default' queue and encryption are used by default. In order to use the queue your app/Http/routes.php file should contain the following route:

Route::post('tasks', array('as' => 'tasks',
function()
{
	return Queue::marshal();
}));

This route will be used by the GAE queue to push the jobs. Please notice that the route and the GAE Queue Connection 'url' parameter point to the same URL. For more information on the matter please see http://laravel.com/docs/master/queues#push-queues.

Cache, Session and Log

Cache, Session and Log components are supported via the use of specific drivers / handlers:

  • Cache - using the 'memcached' driver,
  • Session - using the 'memcached' driver,
  • Log - using 'syslog' handler.

The configuration options for the mentioned drivers / handlers are generated by the artisan command and can be found in .env.production configuration file.

Database

Google Cloud SQL is supported via Laravel's MySql driver. The connection configuration is added by the artisan command to config/database.php under cloudsql. The connection parameters can be configured using --db-socket, --db-name and --db-host options via the artisan command.

The database related environment variables are set in .env.production and .env.local files.

The production environment is configured to use the socket connection while the local configured to connect via the IPv4 address of the Google Cloud SQL instance. Use Google Developers Console in order to obtain the socket connection string and enable the IPv4 address of your database instance.

The migrations are supported while working in local environment only.

To use either the production or the local environment rename the appropriate file to .env.

Filesystem

In order to support Laravel filesystem on GAE the artisan command modifies config/filesystem.php to include an additional disk:

'gae' => [
    'driver' => 'gae',
    'root'   => storage_path().'/app',
],

and adds the following line to .env.production file:

FILESYSTEM = gae

The last but not the least, pull in 'league/flysystem' package via Composer.

"require": {
    "league/flysystem": "~1.0"
}

Optimizations

The optimizations allow the application to reduce the use of GCS, which is the only read-write storage available on GAE platform as of now.

In order to optimize view compilation the included cachefs filesystem can be used to store compiled views using memcached service. cachefs does not provide the application with a reliable storage solution, information stored using memcached is managed according to memcached rules and may be deleted when memcached decides to. Since the views can be compiled again without any information loss it is appropriate to store compiled views using cachefs.

'cachefs' has the following structure:

/
+-- framework
    +-- views

'/framework/views' is used to store the compiled views.

Use the following option to enable the feature in .env.production file:

COMPILED_PATH = cachefs://framework/views

Additionally the initialization of GSC bucket can be skipped to boost the performance:

env_variables:
        GAE_SKIP_GCS_INIT: true

the storage path will be set to /storage directory of the GCS bucket and storage directory structure creation will be skipped.

If not used the filesystem initialization can be removed to minimize GCS usage. In order to do so, remove the following line from .env.production file:

FILESYSTEM = gae

Deploy

Backup the existing .env file if needed and rename the generated .env.production to .env before deploying your app.

Download and install GAE SDK for PHP and deploy your app.

shpasser/gae-support-lumen 适用场景与选型建议

shpasser/gae-support-lumen 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 7.49k 次下载、GitHub Stars 达 13, 最近一次更新时间为 2015 年 06 月 06 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 shpasser/gae-support-lumen 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 shpasser/gae-support-lumen 我们能提供哪些服务?
定制开发 / 二次开发

基于 shpasser/gae-support-lumen 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 7.49k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 14
  • 点击次数: 18
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 13
  • Watchers: 1
  • Forks: 2
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-06-06