Where is Laravel 5.1 Repositories? -


i going through socialite tutorial wich created laravel 5 , i'm using laravel 5.1 , saw there file in tutorial authenticateuser.php in repositories folder. repositories folder don't exist in laravel 5.1. should create file authenticateuser.php in laravel 5.1 ?

laravel uses composer's autoloading, doesn't matter store files, long autoloading mechanism defined in composer.json file. laravel 5 apps start defined in composer.json:

"psr-4": {     "app\\": "app/" } 

so if created directory @ app/repositories, create file in looked this:

<?php namespace app\repositories;  class myrepository {      public function dosomething() {}  } 

then can reference in rest of application this:

<?php namespace app\http\controllers;  use app\repositories\myrepository; use illuminate\routing\controller basecontroller;  foocontroller {      protected $repo;      public function __construct(myrepository $repo)     {         $this->repo = $repo;     }      public function someaction()     {         return $this->repo->dosomething();     } } 

composer load file you, long you've defined mechanism doing so.


Comments