Codeigniter Hmvc Doctrine

CodeIgniter 2 + HMVC + Doctrine 2
Alternatives To Codeigniter Hmvc Doctrine
Project NameStarsDownloadsRepos Using ThisPackages Using ThisMost Recent CommitTotal ReleasesLatest ReleaseOpen IssuesLicenseLanguage
Codeigniterplus130
8 years ago6otherPHP
The Ultimate Codeigniter Enhancements
Codeigniter With Doctrine 295
7 years ago1mitHTML
A simple installation of CodeIgniter 3 with Doctrine 2
Codeigniter Hmvc Doctrine35
11 years ago2otherPHP
CodeIgniter 2 + HMVC + Doctrine 2
Ci App For Ci Phpunit Test29
3 months ago1PHP
CodeIgniter Test Application for ci-phpunit-test
Combustor29
2 years ago16April 18, 20189mitPHP
MVC code generator for the Codeigniter framework.
Codeigniter Doctrine22
5 years ago1mitPHP
A simple Doctrine integration for CodeIgniter 3.x
Codeigniter3 Filename Checker19
5 years ago2mitPHP
CodeIgniter3 Filename Checker
Credo9
3 years ago8December 08, 2018mitPHP
Doctrine ORM integration for the Codeigniter framework.
Codeigniter Doctrine8
10 years ago1PHP
CodeIgniter 2.x , Doctrine 2.x and Composer
Ci3 Doctrine7
8 years agomitPHP
Codeigniter 3 and Doctrine 2.5 example project
Alternatives To Codeigniter Hmvc Doctrine
Select To Compare


Alternative Project Comparisons
Readme

CodeIgniter 2 + HMVC + Doctrine 2

Setup ready to use CodeIgniter framework with:

How to use?

Configuration

Set up application/config/config.php and application/config/database.php for your network.

Load Doctrine library adding it on autoload.php, example:

$autoload['libraries'] = array('doctrine');

Or load Doctrine library in any controller, example:

$this->load->library('doctrine');

Creating models

This setup uses docblock annotations mapping driver and models namespace, you can change it in application/libraries/Doctrine.php.

Example of root model (not in a module), it should be inside application/models:

namespace models;

/**
 * @Entity
 * @Table(name="users")
 */
class User {
	/**
	 * @Id
	 * @Column(type="integer")
	 * @GeneratedValue
	 */
	private $id;

	/**
	 * @Column(type="string", length=32, nullable=false)
	 */
	private $username;
	
	// ...
}

Example of model in a module, it should be inside application/[module_name]/models. Note the difference in namespace:

// Prototype:
// namespace [module_name]\models;
// Example:
namespace auth\models;

class User {
	/**
	 * @Id
	 * @Column(type="integer")
	 * @GeneratedValue
	 */
	private $id;

	/**
	 * @Column(type="string", length=32, nullable=false)
	 */
	private $username;
	
	// ...
}

Creating schemas

To generate automatically schemas for your models you can use the Doctrine console or the schema tool from library:

$this->doctrine->tool->createSchema('auth\models\User');

Other useful methods:

$this->doctrine->tool->dropSchema('auth\models\User');

$this->doctrine->tool->updateSchema('auth\models\User');

Using models

Loading from controllers it's easy, example:

$user = new auth\models\User;
// ...
$this->doctrine->em->persist($user);

You can also shorten the instantiation with the use operator (before class definition):

use auth\models\User;

class Test extends CI_Controller {
	// ...
	
	public function index()
	{
		$user = new User;
		// ...
	}
}

Doctrine console

Doctrine console can be used in terminal from application/third_party/doctrine-orm/bin/doctrine, examples:

php doctrine list

php doctrine orm:schema-tool:create

php doctrine orm:schema-tool:update

php doctrine orm:schema-tool:drop

More information

Popular Doctrine Orm Projects
Popular Codeigniter Projects
Popular Data Processing Categories

Get A Weekly Email With Trending Projects For These Categories
No Spam. Unsubscribe easily at any time.
Php
Codeigniter
Doctrine