定制 arekushi/cycle-orm-factory 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

arekushi/cycle-orm-factory

Composer 安装命令:

composer require arekushi/cycle-orm-factory

包简介

Cycle ORM Factories for Mezzio

README 文档

README

This is a fork of the original repository: https://github.com/sirix777/cycle-orm-factory

This package provides factories for integrating Cycle ORM into the Mezzio framework, providing seamless setup and configuration.

Installation

composer require arekushi/cycle-orm-factory

Configuration

Create a configuration file, for example, config/autoload/cycle-orm.global.php:

<?php

declare(strict_types=1);

use Cycle\Database\Config;
use Sirix\Cycle\Enum\SchemaProperty;


return [
    'cycle'           => [
        'default'     => 'default',
        'databases'   => [
            'default' => [
                'connection' => 'mysql',
            ]
        ],
        'connections' => [
            'mysql' => new Config\MySQLDriverConfig(
                connection: new Config\MySQL\TcpConnectionConfig(
                    database: 'cycle-orm',
                    host: '127.0.0.1',
                    port: 3306,
                    user: 'cycle',
                    password: 'password'
                ),
                reconnect: true,
                timezone: 'UTC',
                queryCache: true,
            ),
        ]
    ],
    'migrator'        => [
        'directory' => 'db/migrations',
        'table'     => 'migrations'
    ],
    'entities'        => [
        'src/App/src/Entity',
    ],
    'schema'   => [
        'property' => SchemaProperty::GenerateMigrations,
        'cache'    => true,
        'directory' => 'data/cache'
    ],
];

Migrator Configuration

'migrator' => [
    'directory' => 'db/migrations',
    'table'     => 'migrations',
],
  • 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

'entities' => [
    'src/App/src/Entity',
],
  • Specifies the directory in which your entity classes are located.

Schema Configuration

'schema' => [
    'property' => null,
    'cache'    => true,
    'directory' => 'data/cache'
],
  • property: Configures the schema property, options include null, SchemaProperty::SyncTables, or SchemaProperty::GenerateMigrations.
  • cache: Enables or disables caching of the generated schema.
  • directory: Specifies the directory in which to store the cached schema.

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.

Use in your project

$container->get('orm'); // Cycle\ORM\ORM
$container->get('dbal'); // Cycle\Database\DatabaseInterface
$container->get('migrator'); // Cycle\Migrations\Migrator

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 two commands for managing database migrations using Cycle ORM. These commands are intended for use with the laminas-cli tool.

1. migrator:migrate Command

Description

The migrator:migrate command performs the necessary database migration steps, applying changes specified in migration files to synchronize your database schema.

Usage

php vendor/bin/laminas migrator:migrate

Options

This command has no additional options.

2. migrator:rollback Command

Description

The migrator:rollback command undoes the changes made by the last migration, reverting your database schema to its previous state.

Usage

php vendor/bin/laminas migrator:rollback

Options

This command does not have any additional options.

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.

arekushi/cycle-orm-factory 适用场景与选型建议

arekushi/cycle-orm-factory 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 9 次下载、GitHub Stars 达 0, 最近一次更新时间为 2024 年 10 月 07 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 arekushi/cycle-orm-factory 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 arekushi/cycle-orm-factory 我们能提供哪些服务?
定制开发 / 二次开发

基于 arekushi/cycle-orm-factory 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 9
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 16
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-10-07