Project Name | Stars | Downloads | Repos Using This | Packages Using This | Most Recent Commit | Total Releases | Latest Release | Open Issues | License | Language |
---|---|---|---|---|---|---|---|---|---|---|
Codeigniterplus | 130 | 8 years ago | 6 | other | PHP | |||||
The Ultimate Codeigniter Enhancements | ||||||||||
Codeigniter With Doctrine 2 | 95 | 7 years ago | 1 | mit | HTML | |||||
A simple installation of CodeIgniter 3 with Doctrine 2 | ||||||||||
Codeigniter Hmvc Doctrine | 35 | 11 years ago | 2 | other | PHP | |||||
CodeIgniter 2 + HMVC + Doctrine 2 | ||||||||||
Ci App For Ci Phpunit Test | 29 | 3 months ago | 1 | PHP | ||||||
CodeIgniter Test Application for ci-phpunit-test | ||||||||||
Combustor | 29 | 2 years ago | 16 | April 18, 2018 | 9 | mit | PHP | |||
MVC code generator for the Codeigniter framework. | ||||||||||
Codeigniter Doctrine | 22 | 5 years ago | 1 | mit | PHP | |||||
A simple Doctrine integration for CodeIgniter 3.x | ||||||||||
Codeigniter3 Filename Checker | 19 | 5 years ago | 2 | mit | PHP | |||||
CodeIgniter3 Filename Checker | ||||||||||
Credo | 9 | 3 years ago | 8 | December 08, 2018 | mit | PHP | ||||
Doctrine ORM integration for the Codeigniter framework. | ||||||||||
Codeigniter Doctrine | 8 | 10 years ago | 1 | PHP | ||||||
CodeIgniter 2.x , Doctrine 2.x and Composer | ||||||||||
Ci3 Doctrine | 7 | 8 years ago | mit | PHP | ||||||
Codeigniter 3 and Doctrine 2.5 example project |
Setup ready to use CodeIgniter framework with:
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');
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;
// ...
}
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');
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 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