shpasser / gae-support
为 Laravel 应用提供 Google App Engine 支持。
Requires
- php: >=5.4.0
- illuminate/support: 4.2.*
Requires (Dev)
- illuminate/console: 4.2.*
- phpunit/phpunit: ~4.4
README
Google App Engine (GAE) 对 Laravel 4 的支持包。
当前支持的功能
- 生成通用配置文件
- 邮件服务提供者
- 队列服务提供者
有关 Laravel 5 的信息,请参阅 https://github.com/shpasser/GaeSupportL5。
有关 Lumen 的信息,请参阅 https://github.com/shpasser/GaeSupportLumen。
安装
通过 Composer 引入此包。
"require": { "shpasser/gae-support": "~1.0" }
然后在 app/config/app.php
中包含服务提供者。
'providers' => [ 'Shpasser\GaeSupport\GaeSupportServiceProvider' ];
使用方法
生成与 GAE 相关的文件/条目。
php artisan gae:setup --config your-app-id
除非使用 --bucket
选项定义自定义存储桶 ID,否则默认配置 GCS 存储桶。
php artisan gae:setup --config --bucket="your-bucket-id" your-app-id
邮件
邮件驱动配置文件可在 app/config/production/mail.php
中找到,它是 artisan 命令生成的多个配置文件之一。无需任何自定义配置。所有发出的邮件都使用应用程序管理员的地址发送,即 admin@your-app-id.appspotmail.com
。支持电子邮件消息的 sender
、to
、cc
、bcc
、replyTo
、subject
、body
和 attachment
部分。
队列
生成的队列配置文件 app/config/production/queue.php
应包含以下内容
return array( 'default' => 'gae', /* |-------------------------------------------------------------------------- | GAE Queue Connection |-------------------------------------------------------------------------- | */ 'connections' => array( 'gae' => array( 'driver' => 'gae', 'queue' => 'default', 'url' => '/tasks', 'encrypt' => true, ), ), );
默认使用 'default' 队列和加密。为了使用队列,您的 app/routes.php
文件应包含以下路由
Route::post('tasks', array('as' => 'tasks', function() { return Queue::marshal(); }));
此路由将由 GAE 队列用于推送作业。请注意,路由和 GAE 队列连接的 'url' 参数指向相同的 URL。有关更多信息,请参阅 https://laravel.net.cn/docs/4.2/queues#push-queues。
部署
下载并安装 PHP 的 GAE SDK 并部署您的应用程序。