Download the PHP package topthink/think-cors without Composer

On this page you can find all versions of the php package topthink/think-cors. 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 think-cors

ThinkCors

ThinkPHP跨域扩展

安装

配置

配置文件位于 config/cors.php

paths 配置示例

允许 api 目录下的跨域请求,* 代表通配符。

当项目有多个域名时,支持为不同域名配置不同的目录。

allowed_origins 配置示例

当配置中有 * 时,代表不限制来源域。

当我们需要限制来源域时,可以这么写。

allowed_origins_patterns 配置示例

除了固定来源域,有时候我们还想要允许不固定但有规则的来源域,那么可以通过正则来实现。例如这里我们允许 thinkphp.cn 的所有二级域。

allowed_methods 配置示例

当配置中有 * 时,代表不限制来源请求方式。

当然我们也可以限制只允许 GETPOST 的跨域请求。

allowed_headers 配置示例

当配置中有 * 时,代表不限制请求头。

当然我们也可以只允许跨域请求只传递给我们部分请求头。

max_age 配置示例

跨域预检结果是有缓存的,如果值为 -1,表示禁用缓存,则每次请求前都需要使用 OPTIONS 预检请求。如果想减少 OPTIONS 预检请求,我们可以把缓存有效期设置长些。 列如这里,我们把有效期设置为 2 小时(7200 秒):

supports_credentials 配置示例

Credentials 可以是 cookiesauthorization headersTLS client certificates。当接口需要这些信息时,开启该项配置后,相关请求将会携带 Credentials 信息(如果有的话)。


All versions of think-cors with dependencies

PHP Build Version
Package Version
Requires topthink/framework Version ^6.0|^8.0
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 topthink/think-cors contains the following files

Loading the files please wait ....