Download the PHP package oksydan/falconize without Composer
On this page you can find all versions of the php package oksydan/falconize. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download oksydan/falconize
More information about oksydan/falconize
Files in oksydan/falconize
Package falconize
Short Description Falconize is a simple tool designed to help you create a database structure and register hooks in PrestaShop modules.
License MIT
Informations about the package falconize
Falconize
Falconize is simple yet powerful tool that helps you to improve you development experience during PrestaShop modules development.
Installation
Usage
Step 1 - Create FalconizeConfiguration
First you need to creat FalconizeConfiguration class that implements FalconizeConfigurationInterface. This class will be used to configure Falconize. Example FalconizeConfiguration class:
Step 2 - Create configuration file
Then create have to create configration file. Configuration file is a yaml file that contains information about database tables and hooks that you want to register/unregister.
Good practice is to place you configuration file inside /modules/my_module/config
directory.
Example configuration file:
Step 3 - Create Falconize instance
Then you need to create Falconize
instance passing FalconizeConfiguration
instance to constructor.
Your main module class have to implement Oksydan\Falconize\PrestaShop\Module\PrestaShopModuleInterface
Step 4 - Use Falconize
When step 3 is done you are able to use Falconize to handle your installation and uninstallation process. Falconize will automatically register/unregister hooks and create/delete database tables. In case of an installation/uninstallation error, Falconize will throw an exception providing information about error.
Usage during upgrade process
When you would like to upgrade your module you are able to use Falconize to handle your upgrade process.
Falconize will automatically register/unregister hooks and upgrade your database schema based on your updated configuration file.
If you change column type, add new column or remove column, add index etc. in your configuration file, Falconize will automatically upgrade your database schema on Falconize::install()
call.
Configuration yaml file
Configuration yaml file contains two main sections: database_tables
and hooks
.
Database tables: database_tables
(array
)
database_tables
section contains information about database tables that you want to create.
Schema is based on Doctrine DBAL schema.
Table name (string
)
Table name is a key of database_tables
section. It has to be unique. It only accepts alphanumeric characters and underscore.
Example:
[!IMPORTANT]
Order of tables is important. It's the same as order of execution.
Columns: columns
(array
)
Columns section contains information about table columns. It is an array of columns. Each column has to have name
and type
keys. Other keys are optional.
Example:
Column name: name
(string
)
Column name is a key of column section. It has to be unique. It only accepts alphanumeric characters and underscore.
Example:
Column type: type
(string
)
Column type is a key of column section. It has to be valid database column type. You can find all available types here.
Example:
Column length length
(integer
) - optional
Column length is a key of column section. It has to be valid column length.
Example:
Column notnull: notnull
(boolean
) - optional
Column notnull is a key of column section. It has to be boolean.
Example:
Column autoincrement: autoincrement
(boolean
) - optional
Column autoincrement is a key of column section. It has to be boolean.
Example:
Column default: default
(mixed
) - optional
Column default is a key of column section. It has to be valid column default value.
Example:
Primary: primary
(array
) - optional
Primary section contains information about primary key. It is an array of column names.
Example:
Indexes: indexes
(array
) - optional
Indexes section contains information about indexes. It is an array of indexes. Each index has to have name
and columns
keys.
Index name: name
(string
)
Index name is a key of index section. It has to be unique. It only accepts alphanumeric characters and underscore.
Index columns: columns
(array
)
Index columns is a key of index section. It has to be an array of column names.
Example:
Constraint keys: constraint_keys
(array
) - optional
Constraint keys section contains information about constraint keys. It is an array of constraint keys. Each constraint key has to have name
, foreign_table
, update
, delete
, local_columns
and foreign_columns
keys.
Constraint key name: name
(string
)
Constraint key name is a key of constraint key section. It has to be unique. It only accepts alphanumeric characters and underscore.
Constraint key foreign table: foreign_table
(string
)
Constraint key foreign table is a key of constraint key section. It has to be valid table name.
Constraint key update: update
(string
)
Constraint key update is a key of constraint key section. It has to be valid constraint key update value. You can find all available values 'NO ACTION'
, 'CASCADE'
, 'SET NULL'
, 'RESTRICT'
, 'SET DEFAULT'
.
Constraint key delete: delete
(string
)
Constraint key delete is a key of constraint key section. It has to be valid constraint key delete value. You can find all available values 'NO ACTION'
, 'CASCADE'
, 'SET NULL'
, 'RESTRICT'
, 'SET DEFAULT'
.
Constraint key local columns: local_columns
(array
)
Constraint key local columns is a key of constraint key section. It has to be an array of column names.
Constraint key foreign columns: foreign_columns
(array
)
Constraint key foreign columns is a key of constraint key section. It has to be an array of column names.
Example:
Hooks: hooks
(array
)
Hooks section contains information about hooks that you want to register/unregister.
Register: register
(array
)
Register section contains information about hooks that you want to register. It is an array of hooks.
Unregister: unregister
(array
)
Unregister section contains information about hooks that you want to unregister. It is an array of hooks.
Hook name: name
(string
)
Hook name is a key of register
/unregister
section. It has to be valid hook name.
Hook version version
(string
) - optional
Hook version is a key of register
/unregister
section. It's PrestaShop version from which hook should be registered/unregistered based on compare operator.
Hook compare operator compare_operator
(string
) - optional
Hook compare operator is a key of register
/unregister
section. It has to be valid hook compare operator. You can find all available values '<'
, '>'
, '='
, '<='
, '>='
.
Example:
Splitting configuration file
You can split your configuration file into multiple files. It might be useful when your .yml file is getting bigger and bigger.
You can create multiple configuration files and then import them into main configuration file.
Example:
File: my_table_name.yml
File: my_table_name_lang.yml
File: hooks.yml
Main configuration file:
[!IMPORTANT]
Order of imports is important. Configuration files are merged in the same order as they are imported.
All versions of falconize with dependencies
symfony/config Version ^5.0
doctrine/dbal Version ^2.13
symfony/yaml Version ^6.0