Download the PHP package liuwave/fc-thinkphp without Composer

On this page you can find all versions of the php package liuwave/fc-thinkphp. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package fc-thinkphp

fc-thinkphp

这是一个使用阿里云函数计算 php runtime搭建serverless thinkphp6.0项目的插件,只需要在函数计算的http触发器入口函数添加几行代码就能让thinkphp6.0运行在函数计算的php运行环境下。

示例:http://test-think.oldmen.cn/

快速开始

首先在thinkphp6.0项目中安装插件:

修改thinkphp项目的入口文件/tp/public/index.php(仅在cgi模式下需要修改(支持cli模式,默认cgi模式)):

函数计算入口index.php中,添加:

API Reference

FcThink::__construct

\Psr\Http\Message\ServerRequestInterface $fcRequest,array $context,$config = []

$fcRequest

函数计算中http触发器传入的$request参数,遵循 PSR(HTTP message interfaces)标准。更多详情请参见 PSR-7-http-message。具体的代码定义遵循 PSR Http Message

$context

函数计算中http触发器传入的context 参数,参见PHP 事件函数 中的 $context参数

$config

配置参数,默认值为:

新手入门

首次使用函数计算,可以参照一下步骤:

1、准备

注:NAS和OSS主要用于储存上传文件,如无需要可不开通

2、安装和配置fun工具

安装和配置参见:安装Fun

3、在函数计算控制台创建服务

进入控制台创建服务1.png

输入名称test-think,可选择绑定日志,点击创建。

输入名称2.png

创建成功后,可在服务配置中修改相关配置(角色权限、日志、NAS等等),具体参见函数计算和RAM相关文档。

4、创建函数和http触发器

在上个步骤中创建的test-think服务器下创建一个函数fc

创建函数4-1.png

选择HTTP函数

选择HTTP函数4-2.png

输入函数名称test-fun,选择php7.2运行环境,其他可默认,触发器中,输入触发器名称test-fun,认证方式选择anonymous,请求方式按照需求选择,这里全选。

配置函数和触发器4-3.png

5、配置自定义域名

在控制台自定义域名下,创建一个自定义域名,绑定到上个步骤中创建的函数

配置自定义域名5-1.png

6、下载代码安装

回到第4步创建的函数test-fun概览界面,点击导出,选择导出配置和代码。

导出配置和代码6-1.png

下载并解压到本地,目录结构如下:

进入 test-fun目录:

创建tp应用(如果已有项目,可跳过此步骤,直接复制项目到此test-think/test-fun目录下)

注:thinkphp 6.0.3中,session的file驱动中缓存目录指定为/rumtime,而这个目录在函数计算时不可写的,会出现错误。 最新的6.0.x-dev开发版中,已经修复这个bug,在发布新版本之前需要使用这个版本:composer require topthink/framework 6.0.x-dev 参见:https://github.com/top-think/framework/pull/2300/commits/264a79521b3062788f5e6cd3c603974ceb63df7e

转到项目目录tp,并安装liuwave/fc-thinkphp

7.修改test-think/test-fun/index.php:

修改tp入口文件test-think/test-fun/tp/public/index.php(仅在cgi模式下需要修改):

8、部署代码

转到根目录/:

执行部署命令(权限策略配置请参考阿里云相关文档):

执行结果8-1.png

访问http://test-think.oldmen.cn/,已成功安装:

执行结果8-2.png

参考

Cli模式 vs cgi模式

默认为cgi模式,可切换为cli模式。

CGI模式

cgi不能在thinkphp项目中调用函数计算内置功能的对象如fcLogger/fcPhpCgiProxy/fcSysLogger。

cgi是通过函数计算提供的$GLOBALS['fcPhpCgiProxy'] 对象实现:

CLI模式

CLI模式支持在thinkphp项目中调用函数计算内置功能的对象如fcLogger/fcPhpCgiProxy/fcSysLogger。

参见liuwave/think-log-driver-sls

VPC权限

如需访问OSS、NAS等资源,需要配置VPC访问权限:配置 VPC 功能

使用OSS上传文件

参考:liuwave/think-filesystem-driver-oss

使用NAS

参见:挂载NAS访问

日志服务

兼容函数计算

参考:liuwave/think-log-driver-sls

开启调试、数据库配置

使用fun部署代码时,会忽略.env,若要开启thinkphp的调试功能、配置数据库,可参照以下方法:

方法一、在部署之后手动添加env文件

在函数计算管理后台,将相关配置写入.env文件(test-think/test-fun/tp/.env(以上文为例))。

方法二、在函数计算项目的根目录下的/template.yml设置环境变量(以上文为例):

注: 需要在添加PHP_前缀,同时需要把.换成_, 并转化成大写,如 PHP_APP_DEBUGPHP_DATABASE_TYPEPHP_DATABASE_HOSTNAME

方法三、在函数计算后台更改

函数 概览 界面中,点击 配置 ,在最下方 添加 或 删除环境变量,的格式 参照 方法二

若使用并开启了liuwave/think-log-driver-sls可在函数计算的对应函数的日志查询功能中查看错误日志。

PHP环境配置

可在根目录 添加 extension文件夹,在其中放入额外的配置 .ini,比如修改文件上传大小的限制:

文件上传,支持单文件和多文件上传

参考:

注,函数计算限制,仅支持不超过6M大小的文件上传或下载,参见使用限制

默认环境中,upload_max_filesize为 2M,可以参照上文PHP环境配置进行更改

BUG提交

Issue

开源许可

The MIT License


All versions of fc-thinkphp with dependencies

PHP Build Version
Package Version
Requires php Version >=7.2.0
topthink/framework Version ^6.0.0
ringcentral/psr7 Version ^1.0@dev
ext-sqlite3 Version *
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package liuwave/fc-thinkphp contains the following files

Loading the files please wait ....