Welcome Guest, Not a member yet? Register   Sign In
Doctrine integration
#10

(11-18-2019, 10:34 AM)ScientiFist Wrote:
(11-18-2019, 05:31 AM)MGatner Wrote: Since it seems like Doctrine already works very nicely with namespaces, and supplies a singular reference and object, I would recommend writing a service definition for it. That time you can load it anywhere you want with `service(‘doctrine’)` and the services will take care of continuity for you.

Amazing thank you a lot, everything is working  Big Grin

So i added doctrine as a service 
PHP Code:
class Services extends CoreServices
{

  //DOCTRINE SERVICE CLASS
  public static function doctrine(){
    // INITIATE
    $doctrine = new \App\Libraries\Doctrine;
    // SHORTCUT ENTITY MANAGER
    $em $doctrine->em;
    // RETURN ENTITY MANAGER
    return $em;
  }



and then im calling it like this in my Home controller
PHP Code:
    public function index()
    {
        
// CALLING THE SERVICE WAY 1
        
$em = \Config\Services::doctrine();
        
// CALLING THE SERVICE WAY 2
    
  //    $em = service('doctrine');

        
$test $em->getRepository('Entities\DebugTable')->findAll();
        
var_dump($test);
        return 
view('welcome_message');
    } 

 Just small question there is not a way to call this service for all my controllers instead of calling it each time i want to use it? 

Quote:Ps: I will send all the files and the explanation how i got doctrine working with code igniter after i received some PM about it


Hello ScientiFist,

Would you be willing to post instructions for using your Doctrine implementation?
I am interested in trying it out!

I've noticed the CodeIgniter4 Playground has Doctrine installed in the vendor directory after performing a
Code:
composer update
, but it lacks any Doctrine implementation example.

Best regards,

Jason Ziegler

(Using CodeIgniter since 1.x)
Reply


Messages In This Thread
Doctrine integration - by ScientiFist - 11-16-2019, 08:26 PM
RE: Doctrine integration - by MGatner - 11-17-2019, 04:39 AM
RE: Doctrine integration - by InsiteFX - 11-17-2019, 04:50 AM
RE: Doctrine integration - by ScientiFist - 11-17-2019, 05:58 PM
RE: Doctrine integration - by MGatner - 11-17-2019, 05:10 AM
RE: Doctrine integration - by MGatner - 11-18-2019, 05:31 AM
RE: Doctrine integration - by ScientiFist - 11-18-2019, 10:34 AM
RE: Doctrine integration - by jasonzig - 11-29-2019, 08:20 AM
RE: Doctrine integration - by MGatner - 11-18-2019, 04:24 PM
RE: Doctrine integration - by ScientiFist - 11-26-2019, 06:29 PM
RE: Doctrine integration - by ScientiFist - 11-30-2019, 07:25 AM
RE: Doctrine integration - by MGatner - 12-01-2019, 05:36 AM
RE: Doctrine integration - by troturier - 12-06-2019, 06:28 AM
RE: Doctrine integration - by ScientiFist - 03-17-2020, 07:06 PM



Theme © iAndrew 2016 - Forum software by © MyBB