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

(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
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
RE: Doctrine integration - by foxbille - 05-10-2024, 11:51 PM
RE: Doctrine integration - by kenjis - 05-11-2024, 02:17 AM
RE: Doctrine integration - by foxbille - 05-11-2024, 05:24 AM
RE: Doctrine integration - by kenjis - 05-13-2024, 06:57 PM
RE: Doctrine integration - by foxbille - 05-18-2024, 09:14 AM



Theme © iAndrew 2016 - Forum software by © MyBB