armenio/armenio-zf2-cakephp-orm-module

The CakePHP Module for Zend Framework 2

1.0.16 2016-06-21 17:20 UTC

This package is not auto-updated.

Last update: 2020-05-27 04:32:24 UTC


README

The CakePHP Module for Zend Framework 2

How to install

  1. Install via composer. Don't know how? Look here

  2. cd my/project/directory

  3. Edit composer.json :

{
	"require": {
		"armenio/armenio-zf2-cakephp-orm-module": "1.*"
	}
}
  1. Edit config/application.config.php :
'modules' => array(
	 'Application',
	 'CakePHP', //<==============================
)
  1. Change your Model namespace in cd my/project/directory/vendor/armenio/armenio-zf2-cakephp-orm-module/config/module.config.php
	'CakePHP' => array(
		'Configure' => array(
			'App' => array(
				'namespace' => 'Custom' //<======= put your App/Module namespace HERE!
			),
		),
	),
  1. Create your models

    6.1. Go to my/project/directory/your/app/namespace

    6.2. Create a directory Model/Table/

    6.3. Go to my/project/directory/your/app/namespace/Model/Table/

    6.4. Create the File MyModelTable.php

<?php
namespace Custom\Model\Table;

use CakePHP\Model\Table as CakePHPTable;

class MyModelTable extends CakePHPTable
{

	protected $_table = 'my_table';

	protected $_alias = 'MyModel';

	protected $_primaryKey = 'id';
}

See more here: http://book.cakephp.org/3.0/en/orm.html

How to use

<?php
use Cake\ORM\TableRegistry;
$table = TableRegistry::get('MyModel');
$all = $table->find('all');