Welcome Guest, Not a member yet? Register   Sign In
CodeIgniter 2 and Doctrine 2
#11

[eluser]hooflung64[/eluser]
Now to just have it work with Modular Separation or the new all in one package.
#12

[eluser]kkruecke[/eluser]
Quote: I tried something similar except that I dont have a CLI.
Assuming you installed Doctrine using pear
Code:
$ sudo pear install pear.doctrine-project.org/doctrineORM

Code:
$ pear list -c pear.doctrine-project.org
Installed packages, channel pear.doctrine-project.org:
======================================================
Package        Version    State
DoctrineCommon 2.0.0RC1   beta
DoctrineDBAL   2.0.0BETA4 beta
DoctrineORM    2.0.0BETA4 beta
and (on Ubuntu, for example) these packages are now located in /usr/share/php/Doctrine
Code:
$ ls -1 /usr/share/php/Doctrine
Common
DBAL
ORM
Symfony
and the doctrine command line utility is installed into /usr/bin. With this setup, then this is a version of cli-config.php you can use. cli-config.php goes in your project's folder. Don't place it in /usr/bin. Change the database connection settings, of course, to your settings.

Code:
<?php
require_once 'Doctrine/Common/ClassLoader.php';

$classLoader = new \Doctrine\Common\ClassLoader('Entities', __DIR__);
$classLoader->register();
$classLoader = new \Doctrine\Common\ClassLoader('Proxies', __DIR__);
$classLoader->register();

$config = new \Doctrine\ORM\Configuration();
$config->setMetadataCacheImpl(new \Doctrine\Common\Cache\ArrayCache);
$driverImpl = $config->newDefaultAnnotationDriver(array(__DIR__."/Entities"));
$config->setMetadataDriverImpl($driverImpl);

$config->setProxyDir(__DIR__ . '/Proxies');
$config->setProxyNamespace('Proxies');

$connectionOptions = array(     'driver' => 'pdo_mysql',
    'dbname' => 'bugs',
     'user' => 'bugs',
    'password' => 'sY7Rsk47',
    ''host' => 'localhost' );

$em = \Doctrine\ORM\EntityManager::create($connectionOptions, $config);

$helperSet = new \Symfony\Component\Console\Helper\HelperSet(array(
    'db' => new \Doctrine\DBAL\Tools\Console\Helper\ConnectionHelper($em->getConnection()),
    'em' => new \Doctrine\ORM\Tools\Console\Helper\EntityManagerHelper($em)
));
There instructions are also at http://wp.me/pj3WD-vn.
#13

[eluser]kkruecke[/eluser]
cli-config.php of course goes in your project directory not in /usr/bin. I didn't make that proint clear.
#14

[eluser]kkruecke[/eluser]
A standalone php program of Doctrine 2 Cookbook example (at least the first portion) is described [url="http://wp.me/pj3WD-vW"]here[/url]
#15

[eluser]g_montel[/eluser]
[quote author="Prophet" date="1284391454"]
So if you would like to create a User class, you need to create application/models/User.php and have it look something like this:
Code:
namespace models;

class User
{
    private $id;
    private $username;
    private $password;
}

You can then do something like $user = new models\User;

I hope this helps somebody, because it took me a while to work out how to load classes like this.[/quote]

THANKS A LOT!
It definitely helped Smile

Geoffroy
#16

[eluser]kkruecke[/eluser]
Of course, you can use place a 'use' statement at the top of the php file in which User will be instantiated. Then you don't need to use the fully qualified name

Code:
<?php
use Models\User;

// snip...

$user = new User; // same thing as: new Models\User
#17

[eluser]g_montel[/eluser]
Thanks!
I didn't manage to make the cli command working though, if anyone wants to help.
Cheers!
#18

[eluser]ephlodur[/eluser]
Hello ...

I need help setting up Codeigniter 2 with Doctrine 2 ..
So far I think I have most thing setup but when I try using an example
with $this->em->flush(); the app just block... I dont know I to debut it...

I have created the table with the cli the get/set with the cli also...
$user = new User;
print_r($user);
$user->setUsername('Eryr');
$user->setPassword('secretPassw0rd');
$this->em = $this->doctrine->em;
$this->em->persist($user);

This is where the code fail
$this->em->flush();

Thanks for any help.
#19

[eluser]ephlodur[/eluser]
Hello ...

I need help setting up Codeigniter 2 with Doctrine 2 ..
So far I think I have most thing setup but when I try using an example
with $this->em->flush(); the app just block... I dont know I to debut it...

I have created the table with the cli the get/set with the cli also...
$user = new User;
print_r($user);
$user->setUsername('Eryr');
$user->setPassword('secretPassw0rd');
$this->em = $this->doctrine->em;
$this->em->persist($user);

This is where the code fail
$this->em->flush();

Thanks for any help.
#20

[eluser]tselaty[/eluser]
For those still having trouble setting up Doctrine 2 and CodeIgniter 2, take a look at the tutorial I wrote on how to integrate CodeIgniter 2 and Doctrine 2.

http://www.tlswebsolutions.com/codeignit...neignited/

-Tim




Theme © iAndrew 2016 - Forum software by © MyBB