Download the PHP package wakebit/laravel-cycle without Composer
On this page you can find all versions of the php package wakebit/laravel-cycle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download wakebit/laravel-cycle
More information about wakebit/laravel-cycle
Files in wakebit/laravel-cycle
Package laravel-cycle
Short Description Cycle ORM integration with Laravel
License MIT
Informations about the package laravel-cycle
Cycle ORM integration with Laravel
This package provides an integration Cycle ORM with Laravel. We are supporting integration both versions of the ORM. Internally, it uses the bridge package that can be used with almost any framework.
Requirements
- PHP >= 8.0
- Laravel 7, 8, 9
The package uses Cycle ORM 1 or 2 (branches v1.x
and v2.x
accordingly).
Installation
-
Install the package via composer:
- Publish the config
cycle.php
:
Usage
- Configure database connection in the
database
config section. You don't need to make any changes if you are already using any of Laravel-compatible database driver. It uses sameDB_*
environment variables. The contents of the key should return a\Cycle\Database\Config\DatabaseConfig
instance. See more here. - Configure paths where your entities located in
tokenizer
section. By default, class locator looks them in app folder.
Define entity:
You can take DBAL, ORM and Entity Manager from the container. Quick example of usage:
See more on the official Cycle ORM documentation.
Working with ORM schema
Schema can be compiled and stored in the cache (recommended for production usage). You can specify the caching driver in cycle.orm.schema
config key:
Commands
Command | Description | Options |
---|---|---|
php artisan cycle:schema:migrate |
Generate ORM schema migrations | - --run : Automatically run generated migration.- -v : Verbose output. |
php artisan cycle:schema:cache |
Compile and cache ORM schema | |
php artisan cycle:schema:clear |
Clear cached schema (schema will be generated every request now) | |
php artisan cycle:schema:sync |
Sync ORM schema with database without intermediate migration (risk operation!) | |
php artisan cycle:schema:render |
Render available Cycle ORM schemas | - --no-color : Display output without colors. |
Database migrations
You can specify the name of migrations table, the path where migrations will be created in cycle.migrations
config key.
Commands
Command | Description | Options |
---|---|---|
php artisan cycle:migrate:init |
Initialize migrator: create a table for migrations | |
php artisan cycle:migrate |
Run all outstanding migrations | - --one : Execute only one (first) migration.- --force : Force the operation to run when in production. |
php artisan cycle:migrate:rollback |
Rollback the last migration | - --all : Rollback all executed migrations.- --force : Force the operation to run when in production. |
php artisan cycle:migrate:replay |
Replay (down, up) one or multiple migrations. | - --all : Replay all migrations. |
php artisan cycle:migrate:status |
Get a list of available migrations |
Database commands
Command | Description | Options |
---|---|---|
php artisan cycle:db:list |
Get list of available databases, their tables and records count | - --database : Database name |
php artisan cycle:db:table <table> |
Describe table schema of specific database | - --database : Database name |
Writing tests
If you are using memory database (SQLite) you can just run migrations in the setUp
method of the your test:
For another databases follow this instruction and drop all tables in the tearDown
method.
Advanced
Manually defined ORM schema
If you want to use a manually defined ORM schema you can define it in the cycle.orm.schema
SchemaConfig
's map
config key (this key is not present by default):
Manually defined schema should be presented as array. It will be passed to \Cycle\ORM\Schema
constructor. See more here.
Custom schema compilation pipeline
You can redefine the ORM schema compilation generators in the cycle.orm.schema
SchemaConfig
's generators
config key (this key is not present by default):
Classes will be resolved by DI container. Default pipeline you can see here in the bridge package.
Using custom collection
By default, ORM uses arrays for collection of items. If you want to use Laravel collections instead of or some another collection you can add the following key to config to orm
section:
The factory class will be resolved by container. It should implement the \Cycle\ORM\Collection\CollectionFactoryInterface
interface.
Notes
- We don't have a plan to create Laravel Facades, magic helpers, etc. You can create them yourself if you need to.
Credits
- Cycle ORM, PHP DataMapper ORM and Data Modelling Engine by SpiralScout.
- Spiral Scout, author of the Cycle ORM.
- Spiral Framework Cycle Bridge for code samples, example of usage.
All versions of laravel-cycle with dependencies
illuminate/console Version ^7.0|^8.0|^9.0|^10.0
illuminate/contracts Version ^7.0|^8.0|^9.0|^10.0
illuminate/support Version ^7.0|^8.0|^9.0|^10.0
wakebit/cycle-bridge Version ^2.1