Download the PHP package uniondrug/structs without Composer

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

Structs component for uniondrug/framework

结构体工具,用于构造数据结构,规范代码和服务之间的数据交互。

使用场景

主要目的是保证在应用中间的业务逻辑层使用统一的结构化数据进行交互,并且保证数据安全可信。

安装

修改 app.php 配置文件,加上StructManager服务。服务名称:structManager

使用

定义结构体

结构体定义了一个数据结构的构成,其属性支持的类型包括标量:string/int(integer)/boolean(bool)/float(double)、另一个结构体,或者是由同一类标量、结构体构成的数组。

1、通过属性注释的@var注解来定义一个属性的类型;

2、当属性是数组的时候,在类型后面加上[]标识;

3、当属性需要设置成只读的时候,使用修饰符protected,为了使IDE友好,可以在类注释中添加@property注解;

4、如果属性没有设置类型,默认是string类型;

注意:属性是数组时,其元素必须是一个结构体,或者是相同类型的标量。是标量类型则必须指定是何种类型,比如:string[],int[]

属性验证

结合uniondrug/validation,可以直接用结构体进行数据验证。

验证规则定义

规则通过注解@Validator定义,说明如下:

type: 字符串或者数组,用到的验证器,可以是单个验证器的名称,也可以是一组验证器。 required: true/false,验证是否必填 empty: true/false,是否可以为空 default: mixed,默认值,如果传入的数据中这个字段为空,或者不存在,则使用该默认值 options: 数组,传给各个验证器的参数,具体根据各个验证器的不同而不同。如果是一组验证器,他们公用这个数组,从里面各取所需。 filters: 字符串或者数组,定义用到的过滤器。用来过滤输入数据。

使用结构体验证数据

使用结构体

1、实例化结构体

注意:数据类型会在初始化的时候进行强制转换,如果数据源的数据类型没法转换成结构体定义的数据类型,会使用结构体定义的默认值,如果没有定义默认值,则是NULL。

首先检查对象是否有结构体需要的属性;

其次检查对象是否有结构体属性同名的方法,有则使用该方法为结构体属性赋值;

最后检查对象是否有get+属性名对应的方法,有则使用该方法为结构体属性赋值;

2、结构体输出

预定义的结构体

分页器结构体是用于直接将Phalcon的分页结果(通过 getPaginate() 方法分页查询的结果)直接转换成结构体。

需要为不同的分页数据定义一个body属性。

输出结构,详见PaginatiorStructPagingStruct

PageRequestStruct,主要用户分页请求。通常作为分页请求的参数的结构体的基类。


All versions of structs with dependencies

PHP Build Version
Package Version
Requires uniondrug/framework Version ^2.0
uniondrug/validation Version ^2.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 uniondrug/structs contains the following files

Loading the files please wait ....