Tencent Cloud ThinkPHP Serverless Component supports deploying RESTful API services based on ThinkPHP 6.x or above.
After the above two steps are completed, use Composer to initialize a
composer create-project topthink/think serverless-thinkphp
Use npm to install Serverless CLI globally:
npm install -g serverless
serverless.yml file in the project root directory:
$ touch serverless.yml
serverless.yml as follows:
# serverless.yml org: orgDemo app: appDemo stage: dev component: thinkphp name: thinkphpDemo inputs: src: src: ./ exclude: - .env region: ap-guangzhou runtime: Php7 apigatewayConf: protocols: - http - https environment: release
Before deployment, you need to run
php think clearto clear the locally running configuration cache.
Deploy by running the
sls command, and you can add the
--debug parameter to view the information during the deployment process:
$ sls deploy --debug
You can run the following command to remove the deployed ThinkPHP project:
$ sls remove --debug
Currently, you can scan a QR code to log in to the CLI by default. If you want to configure persistent environment variables/key information, you can also create a local
touch .env # Tencent Cloud configuration information
Configure Tencent Cloud's
SecretKey information in the
.env file and save it:
# .env TENCENT_SECRET_ID=123 TENCENT_SECRET_KEY=123
You can view more component information in the repository of Serverless Components.