Download the PHP package sirix/cycle-orm-factory without Composer
On this page you can find all versions of the php package sirix/cycle-orm-factory. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package cycle-orm-factory
Mezzio Cycle ORM Factory
Migration Guide: Cycle ORM Factory v1 to v2
This package provides factories for integrating Cycle ORM into the Mezzio framework, providing seamless setup and configuration.
Installation
Configuration
Create a configuration file, for example, config/autoload/cycle-orm.global.php
:
Migrator Configuration
directory
: Specifies the directory where the migration files will be stored.table
: Specifies the name of the table used to store migration information.
Entities Configuration
- Specifies the directory in which your entity classes are located.
Manual mapping schema definitions
You can define manual mapping schema definitions for your entities. This is useful when you need to customize the schema for a specific entity. For example, you can define the table name, primary key, columns, typecast handlers, typecasts, and relations for an entity.
See the Cycle ORM documentation for more information on manual mapping schema definitions.
Schema Configuration
property
: Configures the schema property, options includenull
,SchemaProperty::SyncTables
, orSchemaProperty::GenerateMigrations
.cache.enabled
: Enables or disables caching of the generated schema.cache.key
: Specifies the key used for storing the schema cache. This is optional and can be left empty if not needed.cache.service
: Defines the PSR-6CacheItemPoolInterface
service to be used for schema caching. This allows integration with various caching mechanisms supported in your application. If left out, the default service (with name 'cache') from the container will be utilized if configured.
Schema Property Options
SchemaProperty::SyncTables
The SyncTables option synchronizes the database tables based on the provided entity classes. It ensures that the tables match the structure defined in the entity classes. This can be useful during development when the database schema evolves along with your application.
SchemaProperty::GenerateMigrations
The GenerateMigrations option is used to automatically generate migration files based on changes detected in your entity classes. When enabled, the ORM analyzes the differences between the current database schema and the defined entities. It then generates migration files to apply these changes, making it easier to version and manage your database schema changes.
Select the appropriate SchemaProperty option based on the requirements of your project. Customize the configuration to your needs and enjoy the seamless integration of Cycle ORM with Mezzio.
- Note: The schema properties (e.g., SyncTables, GenerateMigrations) work only with annotated entities.
- Ensure that your entity classes are properly annotated to leverage these features.
Use in your project
These factories provide the necessary components to work seamlessly with Cycle ORM within the Mezzio Framework. Customize the configuration to meet the needs of your project.
For more information about Cycle ORM, see the Cycle ORM documentation.
Migrator Commands
The Sirix\Cycle\Command\Migrator
namespace provides some commands for managing database migrations and the cached Cycle ORM schema. These commands are intended for use with the laminas-cli
tool.
1. cycle:migrator:run
Command
Description
The cycle:migrator:run
command performs the necessary database migration steps, applying changes specified in migration files to synchronize your database schema.
Usage
Options
This command has no additional options.
2. cycle:migrator:rollback
Command
Description
The cycle:migrator:rollback
command undoes the changes made by the last migration, reverting your database schema to its previous state.
Usage
Options
This command does not have any additional options.
3. cycle:migrator:create
Command
Description
The cycle:migrator:create
command generates a new empty migration file in the migration directory.
Usage
Options
migrationName
: The name of the migration file to be created. This should be in PascalCase format.
Note: Make sure that you have correctly configured the database connection and migrations settings in your project's configuration file.
For more information about using migrations with Cycle ORM, see the Cycle ORM Documentation.
4. cycle:cache:clear
Command
Description
The cycle:schema:cache:clear
command clears the cached Cycle ORM schema configuration, forcing the ORM to
regenerate it on the next application run. This can be useful during development when changes to entity definitions or
configurations have been made, and you want to ensure fresh schema generation.
Usage
Options
This command does not have any additional options.
5. cycle:seed:create
Command
Description
The cycle:seed:create
command creates a new seed file in the seed directory. Seed files are used to populate your database with initial or test data.
Usage
Arguments
SeedName
: The name of the seed in PascalCase format (required).
Note: The generated seed file will be placed in the configured seed directory and will implement the SeedInterface
.
6. cycle:seed:run
Command
Description
The cycle:seed:run
command executes a specific seed file, populating your database with the data defined in the seed.
Usage
Arguments
SeedName
: The name of the seed to run in PascalCase format, without the .php extension (required).
Note: The seed class must implement the SeedInterface
and be located in the configured seed directory.
Cache Configuration Example
You can create a Symfony Cache Filesystem Adapter for your application like this:
This configuration creates a Filesystem Cache Adapter with the following parameters:
'cycle'
: A namespace prefix for cache keys, helping to avoid key collisions0
: Default Time-To-Live (TTL) set to infinite, meaning cached items won't expire automatically'data/cycle/cache'
: Directory where cache files will be stored
The cache configuration will look like this:
All versions of cycle-orm-factory with dependencies
composer/package-versions-deprecated Version ^1.11.99
cycle/annotated Version ^4.2
cycle/database Version ^2.11
cycle/entity-behavior Version ^1.3
cycle/entity-behavior-uuid Version ^1.2
cycle/migrations Version ^4.2.5
cycle/orm Version ^2.9
cycle/schema-migrations-generator Version ^2.3
laminas/laminas-cli Version ^1.11.0
psr/cache Version ~1.0.0 || ~2.0.0. || ~3.0.0
symfony/filesystem Version ^6.3 || ^7.2