GoogleAppEngine 1.9.0。 -PHP更新

It’s been a while since I published my Getting Started with PHP on GAE Article, and the platform has been doing better than anyone had expected. The PHP feature request is still at the top of the NFR list, and the Phalcon NFR I created way back then is now sitting at top 17, indicating not only Phalcon’s spread and popularity, but also the liveliness of the PHP community and our desire to see it spread into professional large scale enterprise environments.

自从我在GAE Article上发布《 PHP入门》以来已经有一段时间了,该平台的表现比任何人预期的都要好。 PHP功能请求仍然位于NFR列表的顶部,而我当时创建的Phalcon NFR现在位于第17位,这不仅表明Phalcon的普及和流行,还表明PHP社区的活跃性以及我们对看到它传播到专业的大型企业环境。

On February 26th, the PHP and Python end of GoogleAppEngine’s SDK were updated to version 1.9.0, and this article will aim to explain what was changed regarding PHP. You can find the full release notes here.

2月26日,GoogleAppEngine SDKPHP和Python端更新为1.9.0版 ,本文旨在说明有关PHP的更改。 您可以在此处找到完整的发行说明。

更新 (Updates)

新的口译员次要版本 (New Interpreter Minor Version)

The PHP interpreter has been upgraded from PHP 5.4.19 to PHP 5.4.22.

PHP解释器已从PHP 5.4.19升级到PHP 5.4.22。

I’m not sure why GAE isn’t using the latest version of PHP, but any upgrade is a good upgrade.

我不确定GAE为什么不使用最新版本PHP,但是任何升级都是不错的升级。

5.4.20 fixed several dozen bugs present in 5.4.19, relating to segfaults, incorrect space character encoding when using quoted-printable mode, memory leaks (particularly in cURL), some extension related fixes, and more.

5.4.20修复了5.4.19中存在的数十个错误,这些错误与段错误,使用带引号的可打印模式时空格字符编码不正确,内存泄漏(尤其是在cURL中),一些与扩展相关的修复等有关。

5.4.21. prevented the triggering of auto loading on compile time errors, made sure the built in server treated all http headers as case-insensitive, improved error messages in the DateTime class, fixed IMAP’s configure script and more.

5.4.21。 防止在编译时错误触发自动加载,确保内置服务器将所有http标头视为不区分大小写,改进了DateTime类中的错误消息,修复了IMAP的configure脚本等。

Finally, 5.4.22. fixed some more bugs relating to the built-in server, FTP, Exif, ODBC, Sockets, XMLReader, and other components. You can see the full differences in the version 5 changelog.

最后,5.4.22。 修复了一些与内置服务器,FTP,Exif,ODBC,套接字,XMLReader和其他组件有关的错误。 您可以在版本5 changelog中看到完整的差异。

The latest version of 5.4. is 5.4.26., and we hope GAE adopts it soon, as it does contain some important fixes.

最新版本5.4。 是5.4.26。我们希望GAE尽快采用它,因为它确实包含一些重要的修复程序。

自动加载SDK文件 (Autoloading SDK files)

Autoloading is now available in the SDK so developers will no longer need to explicitly require SDK files.

现在,SDK中提供了自动加载功能,因此开发人员将不再需要显式要求SDK文件。

Previously, to use SDK classes for Google specific services on GAE, you had to manually include them or write an autoloader that did it for you. These classes are now autoloaded by default, so using a class like google\appengine\api\mail\Message is as simple as referencing it.

以前,要将SDK类用于GAE上的Google特定服务,您必须手动将其包括在内或编写为您提供服务的自动加载器。 现在默认情况下会自动加载这些类,因此使用google\appengine\api\mail\Message类的类就像引用它一样简单。

All examples on the GAE SDK documentation site have been updated to reflect this.

GAE SDK文档网站上的所有示例均已更新以反映这一点。

Instead of

代替

require_once 'google/appengine/api/mail/Message.php';
use google\appengine\api\mail\Message;

you now have only

你现在只有

use google\appengine\api\mail\Message;

包括水桶 (Includes from buckets)

  • Expanded php.ini setting google_appengine.allow_include_gs_buckets to allow a path filter to be included for improved security.

    扩展了php.ini设置google_appengine.allow_include_gs_buckets以允许包含路径过滤器以提高安全性。

  • An E_USER_WARNING warning message is now triggered if an application moves a user uploaded file to a Google Cloud Storage bucket/path. This is due to the fact that code may be included and lead to a local file inclusion vulnerability.

    现在,如果应用程序将用户上传的文件移至Google Cloud Storage存储桶/路径,则会触发E_USER_WARNING警告消息。 这是由于可能包含代码并导致本地文件包含漏洞的事实。

These two upgrades come in tandem.

这两个升级是同时进行的。

It is generally possible to include files from Google Cloud Storage buckets, as long as those buckets are defined in the php.ini file under the option google_appengine.allow_include_gs_buckets. The value of this setting is a string with comma separated values, like so: "bucket_1, bucket_2".

只要可以在php.ini文件中的google_appengine.allow_include_gs_buckets选项中定义了这些存储桶,通常就可以包含来自Google Cloud Storage存储桶的文件。 此设置的值是带有逗号分隔值的字符串,例如: "bucket_1, bucket_2"

The first update means we can now include subfolders in the bucket paths for added security. So instead of allowing includes from anywhere in bucket_1, we can allow includes only from bucket_1/includes_allowed, like so:

第一次更新意味着我们现在可以在存储桶路径中包括子文件夹,以提高安全性。 因此,我们可以允许bucket_1/includes_allowed ,而不是允许bucket_1中的任何位置包含bucket_1/includes_allowed ,如下所示:

google_app_engine.allow_include_gs_buckets = "bucket_1/includes_allowed"

This lets you use your bucket for several aspects – classes and files to include, and general storage of other types.

这使您可以将存储桶用于多个方面–包括的类和文件,以及其他类型的常规存储。

The second update means that PHP will emit a warning if you perform the move of an uploaded file into an include-allowed bucket. This is to make sure your users can’t upload PHP scripts into a folder from which they can be included, to prevent LFI attacks. When you see this warning, you should modify your app so that it moves user uploads to an include-disallowed part of the bucket.

第二次更新意味着,如果您将上传的文件移动到允许包含的存储桶中,PHP将发出警告。 这是为了确保您的用户不能将PHP脚本上传到可以包含它们的文件夹中,以防止LFI攻击 。 看到此警告后,您应该修改您的应用,以便将用户上传的内容移动到存储桶中不允许包含的部分。

免费的默认GCS存储桶,元数据访问器 (Free Default GCS Bucket, Metadata accessors)

Newly created App Engine applications now have a Google Cloud Storage bucket created automatically as part of the same Google Cloud Project.

现在,新创建的App Engine应用程序具有作为同一Google Cloud Project一部分自动创建的Google Cloud Storage存储桶。

Previously, if you wanted a Google Cloud Storage bucket for file writes, you had to create one separately and configure it for use with your GAE PHP app. However, since PHP apps so often require disk reads and writes and moving user-uploaded files, the 1.9.0 release automatically creates a fully configured bucket as you start a new project.

以前,如果您想要一个Google Cloud Storage存储桶来进行文件写入,则必须单独创建一个存储桶,并将其配置为与GAE PHP应用程序一起使用。 但是,由于PHP应用程序经常需要磁盘读写和移动用户上传的文件,因此1.9.0版本会在您启动新项目时自动创建完全配置的存储桶。

This bucket has a free quota of 5GB total storage, so your app does not need to be made billable, and can be accessed via the name <app_id>.appspot.com through the gs:// protocol, where app_id is your app’s ID. You can find the name out in the Admin Console under Application Settings, as well.

此存储分区具有5GB总存储空间的免费配额,因此您的应用无需收费,可以通过gs://协议通过名称<app_id>.appspot.com进行访问,其中app_id是您的应用ID 。 您也可以在管理控制台的“应用程序设置”下找到该名称。

Find out more about setting it up and using it here.

在此处了解有关设置和使用它的更多信息。

Fixed an issue with empty Google Cloud Storage folders not displaying correctly in the Developers Console. New folders are now created using the “/” suffix instead of “$folder” so that they are displayed correctly.

修复了空的Google Cloud Storage文件夹无法在开发人员控制台中正确显示的问题。 现在使用“ /”后缀而不是“ $ folder”创建新文件夹,以便正确显示它们。

Added API functions CloudStorageTools::getMetadata() and CloudStorageTools::getContentType() for retrieving the metadata and content type of Google Cloud Storage objects.

添加了API函数CloudStorageTools::getMetadata()CloudStorageTools::getContentType()来检索Google Cloud Storage对象的元数据和内容类型。

The GCS objects you store can also tell you some of their metadata through the new CloudStorageTools::getMetadata() and CloudStorageTools::getContentType() API. To see the full API reference of CloudStorageTools, see here.

您存储的GCS对象还可以通过新的CloudStorageTools::getMetadata()CloudStorageTools::getContentType() API告诉您一些元数据。 要查看CloudStorageTools的完整API参考,请参见此处

PHP_SELF和SCRIPT_NAME修复 (PHP_SELF and SCRIPT_NAME fix)

Due to two bugs, 9989 and 10478, PHP_SELF and SCRIPT_NAME gave the wrong output. This has now been fixed.

由于两个错误998910478 ,PHP_SELF和SCRIPT_NAME给出了错误的输出。 现在,此问题已得到解决。

If you’re wondering where you might want to use these – they’re most commonly used by routing, autoloaders, factory patten realizations, and similar projects where the script being executed has to be aware of its environment.

如果您想在哪里使用它们-路由,自动加载器,工厂模式实现以及类似的项目最常使用它们,执行脚本时必须注意其环境。

SDK的先前版本 (Previous Versions of the SDK)

Previous versions of the SDK added support for the FTP and Zip extension, fixed some more GCS bugs, allowed the sockets API for Billing Enabled Apps, added a CloudStorageTools::getPublicUrl() API for generating a URL for public access to Google Cloud Storage objects, and more. To see the full list, check out the changelog.

早期版本的SDK添加了对FTP和Zip扩展的支持,修复了更多GCS错误,允许启用Billing Enabled Apps的套接字API,添加了CloudStorageTools::getPublicUrl() API,用于生成URL以供公众访问Google Cloud Storage对象, 和更多。 要查看完整列表,请查看changelog

结论 (Conclusion)

GoogleAppEngine’s PHP support has been steadily growing since it was announced, and it’s just heating up. With HHVM on one front, Zephir on the other, and Google-powered PHP in the cloud on the third front, a highly productive war seems to be brewing on the horizon, and whoever wins, the PHP community will benefit. Who do you vote for? Do you use GAE for your PHP apps? Have any interesting deployments you’d like to show us? Would you like to see some more advanced implementation examples? Let us know!

自宣布以来,GoogleAppEngine对PHP的支持一直在稳定增长,并且正在逐步升温。 一个方面是HHVM,另一个方面是Zephir,第三方面是基于GooglePHP,那么一场高产的战争似乎正在酝酿之中,无论谁获胜,PHP社区都将从中受益。 您为谁投票? 您是否将GAE用于PHP应用程序? 您想向我们展示一些有趣的部署吗? 您是否想看一些更高级的实现示例? 让我们知道!

翻译自: https://www.sitepoint.com/googleappengine-1-9-0-php-updates/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值