Download the PHP package activecollab/databasestructure without Composer

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

DatabaseStructure Library

Build Status

Version 1.0 To Do

Fields

Boolean fields with names that start with is_, has_, had_, was_, were_ and have_ also get a short getter. For example, if field name is is_awesome, builder will product two getters: getIsAwesome() and isAwesome().

Password Field

Password field is field meant for storing password hashes. By default, it sets password as field name. It is similar to StringField (uses VARCHAR columns), but it can't have default value (doh!), and it does not have methods for easy indexing (you can still add an index by yourself, if you wish).

JSON Field

JSON field add a JSON field to the type. It will be automatically serialized and deserialized on reads and writes:

On top of regular getters and setters, JSON fields add a modify method. This method receives a callback that will be called with decoded JSON value. Result of the callback is then stored in the field automatically:

JSON fields can store a lot of different data types, so you can't always known which type will be passed to the callback. In our everyday use we noticed that arrays are most common data types that are stored in JSON fields. To ensure that you always get an array, regardless of what is in the field, pass in the second $force_array argument:

System supports value extraction from JSON fields. These values are extracted by MySQL automatically, and they can be stored and indexed.

There are two ways of adding extractors. First is by constructing extractor instance by yourself, and adding it:

Second is by calling extractValue method, which uses provided arguments to construct the appropriate extractor, configure it and add it to the field. Method arguments:

  1. field_name - Name of the generated field,
  2. expression - Expression used to extract the value from JSON. See [https://dev.mysql.com/doc/refman/5.7/en/json-search-functions.html#function_json-extract](JSON_EXTRACT()) MySQL function for details,
  3. default_value - Value that will be used if expression returns NULL,
  4. extractor_type - Class name of the extractor implementation that should be used. Default is ValueExtractor (string value extractor), but there are also extractors for int, float, bool, date, and date and time values,
  5. is_stored - Should the value be permanently stored, or should it be virtual (calculated on the fly on read). Value is stored by default,
  6. is_indexed - Should the value be indexed. Index on the generated field is added when TRUE. FALSE by default.

Example:

Getter methods are automatically added for all generated fields:

Note that values of generated fields can't be set directly. This code will raise an exception:

Associations

Belongs To

Programming to an Interface

Belongs To association supports "programming to an interface" approach. This means that you can set so it accepts (and returns) instances that implement a specific interface:

Has Many

Method that this association will add to Writer model are:

Attributes

Has many association also adds following attributes to the model:

Programming to an Interface

Has Many association support "programming to an interface" approach. This means that you can set so it accepts (and returns) instances that implement a specific interface:

Example:

Has One

Programming to an Interface

Has One association support "programming to an interface" approach. This means that you can set so it accepts (and returns) instances that implement a specific interface:

Example:

Has Many Via

Has and Belongs to Many

Method that this association will add to Writer model are:

Attributes

Has and belongs to many association also adds following attributes to the model:

Structure Options

Structure object support config option setting via setConfig() method. This method can be called during object configuration, of after it has been created:

Following options are available:

  1. add_permissions - Add CRUD permission checks to objects. More…,
  2. base_class_doc_block_properties - Specify an array of properties to be added as @property elements to DocBlock section of generated classes. More….
  3. base_class_extends - Specify which class should built objects extend (ActiveCollab\DatabaseObject\Object is default),

add_permissions

This option tells structure to automatically call permissions() method for all types that are added to it. This option is turned off by default, but it can be enabled by setting it to one of the two values:

  1. StructureInterface::ADD_PERMISSIVE_PERMISSIONS enables permissions and methods that check permissions are set to return true by default;
  2. StructureInterface::ADD_RESTRICTIVE_PERMISSIONS enables permissions and methods that check permissions are set to return false by default.

Example:

base_class_doc_block_properties

Some editors read @property from DocBlock section of the class and know which properties are available via magic methods, which type they are and offer various features based on that info (like code completion, type checking etc). Use base_class_doc_block_properties to specify a list of properties that will be added to the class. Example of the config:

what it builds:

deprecate_long_bool_field_getter

Set to true if you want to have log boolean field getters to be marked as deprecated, when there's a short getter (isAwesome() vs getIsAwesome()).

header_comment

Add a comment that will be included at the header of all auto-generated files. This option is useful if you need to include licensing information in your source code.

Behaviours

Behaviours are interfaces and interface implementations that types and fields add to resulting object classes. These behaviours can do all sort of things: let you element position in collections, store additional bits of information on object level, check user permissions and more.

Permissions Behaviour

When applied, permissions behaviour adds ActiveCollab\DatabaseStructure\Behaviour\PermissionsInterface to object classes, which add four methods that check user permissions over a given object:

  1. canCreate($user)
  2. canView($user)
  3. canEdit($user)
  4. canDelete($user)

All four methods accept only one argument, and that argument needs to be instance that implements \ActiveCollab\User\UserInterface interface.

There are two default implementations that can be added as implementations of PermissionsInterface:

  1. ActiveCollab\DatabaseStructure\Behaviour\PermissionsInterface\PermissiveImplementation is set to return true by default,
  2. ActiveCollab\DatabaseStructure\Behaviour\PermissionsInterface\RestrictiveImplementation is set to return false by default.

Note: Generated code does not enforce these checks prior to doing CRUD operations. It’s up to the application that includes DatabaseStructure library to enforce that these restrictions are applied (in ACL or controller layer for example).

Structure can be configured to apply permissions behaviour to types automatically (see add_permissions structure option). In a situation when you have structure set to automatically add permissions behaviour to types, but you want to turn it off for a particular type, just call permissions(false) again:

Protected Fields Behaviour

This behaviour adds a simple list of proteected fields to the object (accessible using getProtectedFields() method). It's up to the rest of the system to decide what to do with this list, but most common scenario is to disable set of these fields when objects are added using POST or updated using PUT requests:

protectFields ignores empty fields values, and it can be called multiple times:


All versions of databasestructure with dependencies

PHP Build Version
Package Version
Requires php Version >=8.0
ext-mysqli Version *
activecollab/databaseobject Version ^6.0
activecollab/filesystem Version ^0.10
activecollab/user Version ^4.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 activecollab/databasestructure contains the following files

Loading the files please wait ....