Tencent Cloud Laravel Serverless Component supports Laravel v6.0 and above.
Use npm to install Serverless CLI globally:
npm install -g serverless
The following steps are mainly for deployment on the command line. For deployment in the console, please see Console Deployment Guide.
If you don't have a local Laravel project, you can initialize a Laravel project with the following commands (if you already have one, you can ignore this step):
serverless init laravel-starter --name example cd example
serverless.yml file in the project root directory:
Paste the following configuration template into the file to implement basic project configuration.
You can add more configuration items in
serverless.ymlbased on your actual deployment needs. For more information on the configuration of the .yml file, please see Laravel Component Configuration.
# serverless.yml component: laravel name: laravelDemo org: orgDemo app: appDemo stage: dev inputs: src: ./ region: ap-guangzhou runtime: Php7 apigatewayConf: protocols: - http - https environment: release
Deploy by running the
sls deploy command, and you can add the
--debug parameter to view the information during the deployment process:
sls deploy --debug
After the deployment is completed, access the application by accessing the output API Gateway link.
After the deployment is completed, you can log in to the Serverless Framework console to view the basic information of the application and monitor logs.
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