armenio / armenio-zf2-cakephp-orm-module
The CakePHP Module for Zend Framework 2
1.0.16
2016-06-21 17:20 UTC
Requires
- cakephp/cache: 3.*
- cakephp/log: 3.*
- cakephp/orm: 3.*
- zendframework/zendframework: 2.*
README
The CakePHP Module for Zend Framework 2
How to install
-
Install via composer. Don't know how? Look here
-
cd my/project/directory
-
Edit composer.json :
{ "require": { "armenio/armenio-zf2-cakephp-orm-module": "1.*" } }
- Edit config/application.config.php :
'modules' => array( 'Application', 'CakePHP', //<============================== )
- 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! ), ), ),
-
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');