Laravel 4: Confused about how to use App::make()

后端 未结 2 1525
借酒劲吻你
借酒劲吻你 2021-02-06 05:39

I am trying to follow the repository pattern outlined in this article http://code.tutsplus.com/tutorials/the-repository-design-pattern--net-35804#highlighter_174798 And I am try

2条回答
  •  猫巷女王i
    2021-02-06 06:24

    App is actually a facade for Laravel IoC container usually used for automatic resolution. Understanding of IoC concept is vital for complex application development but small projects will benefit from well architecture for sure. I would recommend to dive into Laravel documentation first and try some examples on Service Providers, Bindings and Automatic Resolution.

    Speaking about your example:

    namespace My;
    
    class NewClass {
    
        function __construct($id, $title) 
        {
            $this->id    = $id;
            $this->title = $title;
        }
    }
    
    
    $newClass = App::make('My\NewClass', [1, 'test']);
    

提交回复
热议问题