cloudframework-io / backend-core-php8
CLOUDRAMEWORK PHP8 核心框架,用于开发针对 APPENGINE、FUNCTIONS、KUBERNETS 等服务器技术的优化后端 API 和脚本
8.3.27
2024-09-30 08:27 UTC
Requires
- google/apiclient: ^2.15
- google/cloud-bigquery: ^1.28
- google/cloud-datastore: ^1.26
- google/cloud-logging: ^1.28
- google/cloud-pubsub: ^1.48
- google/cloud-secret-manager: ^1.12
- google/cloud-storage: ^1.36
- google/cloud-tasks: ^1.13
- google/cloud-translate: ^1.17
- zbateson/mail-mime-parser: ^2.4
- dev-main
- 8.3.27
- 8.3.26
- 8.3.25
- 8.3.24
- 8.3.23
- 8.3.22
- 8.3.21
- 8.3.20
- 8.3.19
- 8.3.18
- 8.3.17
- 8.3.16
- 8.3.15
- 8.3.14
- 8.3.13
- 8.3.12
- 8.3.11
- 8.3.10
- 8.3.9
- 8.3.8
- 8.3.7
- 8.3.6
- 8.3.5
- 8.3.4
- 8.3.3
- 8.3.2
- 8.3.1
- 8.1.23
- 8.1.22
- 8.1.21
- 8.1.20
- 8.1.19
- 8.1.18
- 8.1.17
- 8.1.16
- 8.1.15
- 8.1.14
- 8.1.13
- 8.1.12
- 8.1.11
- 8.1.10
- 8.1.9
- 8.1.8
- 8.1.7
- 8.1.6
- 8.1.5
- 8.1.4
- 8.1.3
- 8.1.2
- 8.1.1
- dev-development
- dev-feature/workflow-email-bcc
This package is auto-updated.
Last update: 2024-09-30 08:31:23 UTC
README
CLOUDRAMEWORK PHP8 核心框架,用于开发针对 GOOGLE APPENGINE、COMPUTE ENGINE、CLOUD FUNCTIONS、KUBERNETS 等服务器技术的优化后端 API 和脚本。
假设您已在服务器上安装了 ^PHP8.1 和 ^Python3.X
GitHub 项目和包可以在以下位置找到
- https://github.com/CloudFramework-io/backend-core-php8
- https://packagist.org.cn/packages/cloudframework-io/backend-core-php8
首次安装和运行带有 Hello World API 的本地服务器
第一步是安装基本库
composer require cloudframework-io/backend-core-php8 # if you have problem with GRPC extensions you can use: # composer require cloudframework-io/backend-core-php8 --ignore-platform-req=ext-grpc
现在您需要创建您的基本文件结构
php vendor/cloudframework-io/backend-core-php8/install.php # It will create the following structure: - mkdir ./local_data/cache - Copying /api examples - Copying /scripts examples - Copying composer.json - Copying .gitignore - Rewriting composer.json - Copying app.yaml for GCP appengine - Copying .gcloudignore - Copying README.md - Copying php.ini
现在您可以使用您的第一个 API Hello world 启动您的本地服务器
composer server # And you can add a browser and navigate to: # https://:8080/ # https://:8080/training/hello # https://:8080/training
https://:8080/ 的响应将是 JSON
{ "success": true, "status": 200, "code": "ok", "time_zone": "UTC", "data": { "end-point /index [current]": "This end-point defined in <document-root>/api/index.php", "end-point /training/hello": "Advanced API Structure of Hello World in <document-root>/api/training/hello-advanced.php", "Current Url Parameters: $this->params": [], "Current formParameters: $this->formParams": [] }, "logs": [ "[syslog:info] CoreCache: init(). type: directory", "[syslog:info] RESTful: Url: [GET] https://:8080/" ] }
探索文件 /api/training/hello.php 和 hello-advanced.php 以查看 API 的基本结构。
配置您的项目以在 GCP(Google Appengine)中部署,以及与 CloudFramework CLOUD-PLATFORM 交互
在设置本地开发环境之前,请确保您已在计算机上安装了 GCP SDK。
运行以下 composer 命令以配置您的开发环境
composer setup
MAC 开发环境
如果您是使用 zsh shell 的 Mac 用户,设置将询问您是否要配置 .zshrc 以包含一些变量、别名和函数,以方便您的开发生活。
> php vendor/cloudframework-io/backend-core-php8/runscript.php _setup
CloudFramWork (CFW) Core7.Script 8.1.x
- Looking for scripts of the framework because the name start with [_]
- root_path: /Users/adrianmartinez/Develoment/GCP/api.cloudframework.io/appengine/core24
- app_path: ./vendor/cloudframework-io/backend-core-php8/scripts
- script: ./vendor/cloudframework-io/backend-core-php8/scripts/_setup.php
- Initial Logs:
#[syslog:info] CoreSession: init(). id [CloudFrameworkScripts]
#[syslog:info] CoreCache: init(). type: directory
##########################
SHELL configuration
- current shell: [/bin/zsh]
# Do you want auto configuration of [/Users/adrianmartinez/.zshrc] [yes, no] (yes) :
如果您回答 [yes],它将添加一些别名和函数
# Analyzing /Users/adrianmartinez/.zshrc
. Adding header [# BEGIN CloudFramework ALIASES AND FUNCTIONS]
. Found tag [# END CloudFramework ALIASES AND FUNCTIONS]
# Adding alias [# Cloudframework ALIASES]
# Adding alias [alias cfserve='composer run-script serve']
# Adding alias [alias cfdeploy='composer run-script deploy']
# Adding alias [alias cfcredentials='composer run-script install-development-credentials']
# Adding alias [alias cfscript='composer run-script script']
# Adding alias [alias cffront="python cf_http_dev.py 5000 'Pragma: no-cache' 'Cache-Control: no-cache' 'Expires: 0' 'Access-Control-Allow-Origin: *'"]
# Adding alias [alias cfgen_password='openssl rand -base64 21']
# Adding alias [alias cfreload_source='source ~/.zshrc']
# Adding alias [# Cloudframework Functions]
# Adding function [function gcp () {]
# Adding function [function gsecret () {]
# File updated. Execute [source ~/.zshrc]
CLOUD-PLATFORM 配置
如果您是 CloudFramwork 客户,您可以配置与您的平台相连的开发环境。不用担心,此选项完全是可选的,并且不是必需的。
CORE ./config.json
- GCP configuration config vars
# core.erp.platform_id: CF/ERP Platform Id (empty if you do not have any access) :
Google GCP 配置
如果您有兴趣在 APPENGINE 下部署您的 API,则需要提供 GCP 配置
# core.gcp.project_id: DEFAULT PROJECT_ID for GCP (<default-project>>) : # core.gcp.datastore.on: Activate Datastore access [true, false] (false) : # core.gcp.datastore.project_id: Default project_id for datastore. Empty if it is the same than core.gcp.project_id : # core.gcp.datastorage.on: Activate Storage access [true, false] (false) : # core.gcp.datastorage.project_id: Default project_id for datastorage. Empty if it is the same than core.gcp.project_id : # core.gcp.bigquery.on: Activate Bigquery access [true, false] (false) : # core.gcp.bigquery.project_id: Default project_id for bigquery. Empty if it is the same than core.gcp.project_id : # core.cache.cache_path: Development Cache Path (<document-root>/local_data/cache) : - Updated ./config.json ########################## Script: OK