<legend id='fMrKo'><style id='fMrKo'><dir id='fMrKo'><q id='fMrKo'></q></dir></style></legend>
  • <small id='fMrKo'></small><noframes id='fMrKo'>

  • <tfoot id='fMrKo'></tfoot>
      <i id='fMrKo'><tr id='fMrKo'><dt id='fMrKo'><q id='fMrKo'><span id='fMrKo'><b id='fMrKo'><form id='fMrKo'><ins id='fMrKo'></ins><ul id='fMrKo'></ul><sub id='fMrKo'></sub></form><legend id='fMrKo'></legend><bdo id='fMrKo'><pre id='fMrKo'><center id='fMrKo'></center></pre></bdo></b><th id='fMrKo'></th></span></q></dt></tr></i><div id='fMrKo'><tfoot id='fMrKo'></tfoot><dl id='fMrKo'><fieldset id='fMrKo'></fieldset></dl></div>
        <bdo id='fMrKo'></bdo><ul id='fMrKo'></ul>

        Laravel 4:对如何使用 App::make() 感到困惑

        Laravel 4: Confused about how to use App::make()(Laravel 4:对如何使用 App::make() 感到困惑)

              <tbody id='MLJgV'></tbody>
            <legend id='MLJgV'><style id='MLJgV'><dir id='MLJgV'><q id='MLJgV'></q></dir></style></legend>
              <bdo id='MLJgV'></bdo><ul id='MLJgV'></ul>

              <tfoot id='MLJgV'></tfoot>

            • <small id='MLJgV'></small><noframes id='MLJgV'>

                <i id='MLJgV'><tr id='MLJgV'><dt id='MLJgV'><q id='MLJgV'><span id='MLJgV'><b id='MLJgV'><form id='MLJgV'><ins id='MLJgV'></ins><ul id='MLJgV'></ul><sub id='MLJgV'></sub></form><legend id='MLJgV'></legend><bdo id='MLJgV'><pre id='MLJgV'><center id='MLJgV'></center></pre></bdo></b><th id='MLJgV'></th></span></q></dt></tr></i><div id='MLJgV'><tfoot id='MLJgV'></tfoot><dl id='MLJgV'><fieldset id='MLJgV'></fieldset></dl></div>
                  本文介绍了Laravel 4:对如何使用 App::make() 感到困惑的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我正在尝试遵循本文中概述的存储库模式 http://code.tutsplus.com/tutorials/the-repository-design-pattern--net-35804#highlighter_174798 我正在尝试使用 App::make() 在 Laravel 中实例化一个类(我猜是 Laravel 的工厂模式吗?)我正在尝试解析我的课程的参数,但我不知道该怎么做.

                  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 trying to instantiate a class in Laravel using App::make() (Which I am guessing is Laravel's factory pattern?) and I am trying to parse arguments to my class but I can't work out how to do it.

                  代码:

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

                  谁能指出如何使用 App::make() 的示例,还是我走错了方向,不应该使用 App::make()?

                  Can anyone point to an example of how to use App::make() or have I gone in the completely wrong direction and shouldn't be using App::make()?

                  推荐答案

                  Laravel 论坛的好心人为我解答了这个http://laravel.io/forum/02-10-2014-laravel-4-confused-about-how-to-使用-appmake

                  The good people in the Laravel forum answered this one for me http://laravel.io/forum/02-10-2014-laravel-4-confused-about-how-to-use-appmake

                  如果您可以使用 App::bind(); 绑定自定义实例化代码,就差不多了像这样

                  Pretty much if you can bind custom instantiation code with App::bind(); like so

                  App::bind('MyNewClass', function() use ($classArgs) {
                      return new MyNewClass($classArgs['id'], $classArgs['title']);
                  });
                  
                  // get the binding
                  $newClass = App::make('MyNewClass');
                  

                  这篇关于Laravel 4:对如何使用 App::make() 感到困惑的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  DeepL的翻译效果还是很强大的,如果我们要用php实现DeepL翻译调用,该怎么办呢?以下是代码示例,希望能够帮到需要的朋友。 在这里需要注意,这个DeepL的账户和api申请比较难,不支持中国大陆申请,需要拥有香港或者海外信用卡才行,没账号的话,目前某宝可以
                  PHP通过phpspreadsheet导入Excel日期,导入系统后,全部变为了4开头的几位数字,这是为什么呢?原因很简单,将Excel的时间设置问文本,我们就能看到该日期本来的数值,上图对应的数值为: 要怎么解决呢?进行数据转换就行,这里可以封装方法,或者用第三方的
                  mediatemple - can#39;t send email using codeigniter(mediatemple - 无法使用 codeigniter 发送电子邮件)
                  Laravel Gmail Configuration Error(Laravel Gmail 配置错误)
                  Problem with using PHPMailer for SMTP(将 PHPMailer 用于 SMTP 的问题)
                  Issue on how to setup SMTP using PHPMailer in GoDaddy server(关于如何在 GoDaddy 服务器中使用 PHPMailer 设置 SMTP 的问题)

                          <tbody id='SJpDw'></tbody>
                        <i id='SJpDw'><tr id='SJpDw'><dt id='SJpDw'><q id='SJpDw'><span id='SJpDw'><b id='SJpDw'><form id='SJpDw'><ins id='SJpDw'></ins><ul id='SJpDw'></ul><sub id='SJpDw'></sub></form><legend id='SJpDw'></legend><bdo id='SJpDw'><pre id='SJpDw'><center id='SJpDw'></center></pre></bdo></b><th id='SJpDw'></th></span></q></dt></tr></i><div id='SJpDw'><tfoot id='SJpDw'></tfoot><dl id='SJpDw'><fieldset id='SJpDw'></fieldset></dl></div>
                      • <tfoot id='SJpDw'></tfoot>
                      • <legend id='SJpDw'><style id='SJpDw'><dir id='SJpDw'><q id='SJpDw'></q></dir></style></legend>

                            <bdo id='SJpDw'></bdo><ul id='SJpDw'></ul>

                            <small id='SJpDw'></small><noframes id='SJpDw'>