PHPackages                             sevenways/zor - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Framework](/categories/framework)
4. /
5. sevenways/zor

AbandonedArchivedLibrary[Framework](/categories/framework)

sevenways/zor
=============

Module for Zend Framework 2

097PHP

Since Jun 13Pushed 9y ago1 watchersCompare

[ Source](https://github.com/SevenWays/ZOR)[ Packagist](https://packagist.org/packages/sevenways/zor)[ RSS](/packages/sevenways-zor/feed)WikiDiscussions master Synced yesterday

READMEChangelogDependenciesVersions (1)Used By (0)

```
            Zend On Rails by Sergej Hoffmann 0.9.1beta

```

This Module implements some functions of Ruby On Rails, such as the ActiveRecord Pattern and Migrations

```
                    ZendOnRails Instruction

```

Installation required programs.

```
  sudo apt-get install php7.0 php7.0-zip php7.0-intl php7.0-xml php7.0-sqlite

  sudo apt-get install composer

  sudo apt-get install git

```

Installation packages.

```
Create Project Folder.
        mkdir
Navigate to the project folder.
        cd
Install the required packages with "Composer".

        composer require sevenways / zor: dev-master

```

Create

```
        alias ​​zor = 'vendor/sevenways/zor/bin/zor.php'

```

or use

```
    ./vendor/bin/zor.php

                  Working with ZendOnRails module

```

```
  zor.php create project [--path=]    Create an application. It uses  ZendApplicatioSkeleton

  [--path]    Optional if workspace differently

  zor.php create module --name= [--path=]    Create a module. It uses ZendModuleSkeleton

  [--name]    Name of Module
  [--path]    Optional if workspace differently

  zor.php create fmodule --require= [--path=]    Create a foreign module from packagist.org

  [--require]    Package name from packagist.org
  [--path]       Optional if workspace differently

  zor.php create database [--name=] [--driver=] [--username=] [--password=]    Create a database adapter. Default Sqlite

  [--name]        Name of tabel
  [--driver]      Zend Farmework supports drivers
  [--username]    Database username
  [--password]    Database password

  zor.php generate ctrl --name= [--module=] [--actions=]    Generate a controller

  [--name]       Name of controller
  [--module]     Name of module. Default: "Application"
  [--actions]    Names of actions. Default: "index"

  zor.php generate act [--cname=] [--module=] [--actions=]    Generate the actions for a controller

  [--cname]      Name of controller
  [--module]     Name of module. Default:"Application"
  [--actions]    Names of actions. Default: "index"

  zor.php generate model [--name=] [--module=] [--columns=]    Generate a model with ActiveRecord pattern

  [--name]       Name of model
  [--module]     Name of module. Default:"Application"
  [--columns]    A string of attributs.

  Structure of the string for the Columns: first_name:type{length}:primerykey/uniquekey,next_column:type{length}:Primerykey/uniquekey,...

  zor.php generate migration [--name=] [--columns=]    Generate a migration

  [--name]       Name of migration
  [--columns]    A string of attributs

  Structure of the string for the Columns:

    first_name:type{length}:primerykey/uniquekey,next_column:type{length}:Primerykey/uniquekey,...

  zor.php run server [--host=] [--port=] [--path=]    Run buildin PHP server

  [--host]    Name of migration. Default: "localhost"
  [--port]    Port nummber. Default: "8080"
  [--path]    Path to index.php. Default: "/public"

  zor.php db migrate [--version]     Run migration to database
  zor.php db rollback [--version]    Run rollback to database

  [--version]    Version of migration. Default: any

```

```
           Working with ActiveRecord

```

Create database / model. The ZOR generated the model and migration with command:

```
  zor.php generate model [--name =] [--module=] [--columns=]

```

The attributes id, created\_at, and updated\_at are generated automatically. There are two ways to create the model:

First method: The generator binds every generated Model in Service Manager. This allows us to create the access from controller with the following call:

```
$obj = $this->serviceLocator->get('Namespace\Model\ModelName');

```

Because each ActiveRecord object implements an AdapterAwareInterface, Database Adapter is automatically added by the ServiceManager.

Second method: Via normal object generation, you have to transfer the database adapter to created object.

```
$obj = new ModelName();
$obj-> setDbAdapter($adapterObject);

```

```
            Add and modify records

```

The records can be added in two ways.

```
$obj->create(array (field_name1 => value, field_name2 => value, ...));
$obj->bind(array (field_name1 => value, field_name2 => value, ...));

```

Where `bind()` method is to execute `save()` method.

```
$obj->update_attributes(array (field_name1 => 'value', field_name2 => 'value', ...));
$obj->columnName = 'value';

```

For the individual changes of the values, one must execute the save() method.

```
$obj->save();

```

Useful methods:

```
$obj->isNewRecord();   // Verifies if Model is stored in the database.

$obj->isChanged();     // Returns whether a column value has been changed

```

```
        Working with individual entries

```

```
first($like=1) - returns the first entry from the database
last($like=1) - returns the last entry from the database
all() - returns all entries from the database
take($like) - is synonymous with first() where argument $like is required
find($id) - searches for one or more entries in the database by attributes(PrimaryKey). For multiple entries, you must pass ID as array().
find_by_attribute($name, $argument) - looks for an entry using the attribute name and value.

find_or_create_by_attribute ($column, $argument, $_) - this function checks if an entry exists, otherwise it inserts new.

```

With $\_ variable you can pass an array with associated attributes and their value.

There are called magical methods:

```
find_by_* ($value);
find_or_create_by_* ($value, $_=null);

```

Instead of the asterisk, set the name of the attribute.

```
        Working with relationship 1:N

```

You have to make the settings in both models:

In the Model\_1:

```
protected $ has_many = array('model_N' => array('class' => 'Namespace\ModelName');

```

In the Model\_N:

```
protected $ belongs_to = array('model_1' => array ('class' => 'Namespace\ModelName', 'foreign_key_attribute' => 'model_name_id', 'foreign_key' => null);

$nModel = $ obj->NameOfNModel(); //gets new N-model

$obj->NameOfNModel()->create(array(field_name => value));
$all_n_mdele = $obj->NameOfNModel()->all(); // returns an array of N-relationship models.

```

```
        Working with relationship M:N

```

M:N relationships need one third Tabele, we can create one by means of generator the tabele.

Generate model Model\_B\[--module =\] --columns=Model\_M:references, Model\_N:references

In the Model\_B:

```
protected $ has_many = array('Model_M' => array ('class' => 'Namespace\ModelName_M'),
                             'Model_N' => array('class' => 'Namespace\ModelName_N'));

```

In the Model\_M:

```
protected $ has_many = array ('Model_N' => array('class' => 'Namespace\ModelName','through' => 'Model_B');

```

In the Model\_N:

```
protected $ belongs_to = array ('Model_M' => array ('class' => 'namespace\ModelName', 'foreign_key_attribute' => 'model_name_id', 'foreign_key' => null);

```

###  Health Score

21

—

LowBetter than 18% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/10261770?v=4)[Sergej Hoffmann](/maintainers/SevenWays)[@SevenWays](https://github.com/SevenWays)

---

Top Contributors

[![SevenWays](https://avatars.githubusercontent.com/u/10261770?v=4)](https://github.com/SevenWays "SevenWays (3 commits)")

### Embed Badge

![Health badge](/badges/sevenways-zor/health.svg)

```
[![Health](https://phpackages.com/badges/sevenways-zor/health.svg)](https://phpackages.com/packages/sevenways-zor)
```

###  Alternatives

[laravel/socialite

Laravel wrapper around OAuth 1 &amp; OAuth 2 libraries.

5.7k104.3M836](/packages/laravel-socialite)[laravel/dusk

Laravel Dusk provides simple end-to-end testing and browser automation.

1.9k38.6M289](/packages/laravel-dusk)[nineinchnick/edatatables

Grid widget for the Yii Framework, wrapper for the DataTables jQuery plugin

173.2k](/packages/nineinchnick-edatatables)[link-cloud/fast-hyperf

LinkCloud Fast Hyperf

241.2k1](/packages/link-cloud-fast-hyperf)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
