• <tfoot id='HTZX1'></tfoot>

  • <legend id='HTZX1'><style id='HTZX1'><dir id='HTZX1'><q id='HTZX1'></q></dir></style></legend>
      <bdo id='HTZX1'></bdo><ul id='HTZX1'></ul>

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

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

      1. 如何在 laravel 4 中自动加载“库"?

        How to autoload #39;libraries#39; in laravel 4?(如何在 laravel 4 中自动加载“库?)

          <tbody id='M6GmW'></tbody>
        <tfoot id='M6GmW'></tfoot>
          <bdo id='M6GmW'></bdo><ul id='M6GmW'></ul>

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

                  <i id='M6GmW'><tr id='M6GmW'><dt id='M6GmW'><q id='M6GmW'><span id='M6GmW'><b id='M6GmW'><form id='M6GmW'><ins id='M6GmW'></ins><ul id='M6GmW'></ul><sub id='M6GmW'></sub></form><legend id='M6GmW'></legend><bdo id='M6GmW'><pre id='M6GmW'><center id='M6GmW'></center></pre></bdo></b><th id='M6GmW'></th></span></q></dt></tr></i><div id='M6GmW'><tfoot id='M6GmW'></tfoot><dl id='M6GmW'><fieldset id='M6GmW'></fieldset></dl></div>
                  本文介绍了如何在 laravel 4 中自动加载“库"?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我在 app 文件夹中创建了一个库文件夹来添加我的应用程序库.我已经更新了应用程序配置文件和 composer.json 以自动加载该文件夹,但是当我运行命令 composer dump-autoload 时,我收到下一个错误:

                  I've created a library folder in app folder to add my app libraries. I've updated app config file and composer.json to autoload that folder, but when I run the command composer dump-autoload I get the next error:

                  {"error":{"type":"Symfony\Component\Debug\Exception\FatalErrorException","message":"Class 'App\Libraries\Search\SearchServiceProvider'未找到","file":"D:\Users\Miguel Borges\Documents\Trabalhos\Tese\portal\bootstrap\compiled.php","line":4130}}PHP 致命错误:第 4130 行的 D:UsersMiguel BorgesDocumentsTrabalhosTeseportalootstrapcompiled.php 中找不到类 'AppLibrariesSearchSearchServiceProvider'[1.1s 完成,退出码 255]

                  我的应用文件夹树:

                  app
                  | ...
                  + libraries
                  | + search
                  | | - Search.php
                  | | - SearchFacade.php
                  | | - SearchServiceProvider.php
                  | + lib2
                  | | - ...
                  | + lib3
                  | | - ...
                  | | - Theme.php
                  | - ...
                  - filters.php
                  - routes.php
                  

                  SearchServiceProvider.php

                  namespace AppLibrariesSearch;
                  
                  use IlluminateSupportServiceProvider;
                  
                  class SearchServiceProvider extends ServiceProvider {
                  
                      /**
                       * Register the service provider.
                       *
                       * @return void
                       */
                      public function register()
                      {
                          $this->app['search'] = $this->app->share(function($app)
                          {
                              return new Search;
                          });
                      }
                  
                  }
                  

                  composer.json

                      "autoload": {
                          "classmap": [
                              "app/commands",
                              "app/controllers",
                              "app/models",
                              "app/libraries",
                              "app/database/migrations",
                              "app/database/seeds",
                              "app/tests/TestCase.php"
                          ]
                          // ,
                    //       "psr-0": {
                    //           "app": "app/libraries"
                    //       }
                      },
                  

                  基本上,我需要自动加载库"文件夹中的所有库.

                  Basically, I need to autoload all the libraries within the 'libraries' folder.

                  推荐答案

                  您应该为您的应用程序创建一个顶级命名空间.

                  You should create a top-level namespace for your application.

                  然后将所有库代码放在该命名空间下.注意:任何第三方库都应该(希望)通过 Composer 安装,因此有自己的命名空间/自动加载设置.

                  Then put all libraries you code under that namespace. Note: Any third-party libraries should (hopefully) be installed via Composer and therefore have its own namespace/autoloading setup.

                  您的目录结构将是:

                  libraries
                      Myapp
                          Search (note directory is capitalized)
                              Search.php
                              SearchFacade.php
                              SearchServiceProvider.php
                          AnotherLib
                  

                  然后您的类将遵循该命名空间:

                  Then your classes will follow that namespace:

                  文件:Myapp/Search/Search.php:

                  <?php namespace MyappSearch;
                  
                  class Search { ... }
                  

                  最后,您的自动加载设置:

                  And finally, your autoloading setup:

                  "autoload": {
                      "classmap": [
                          "app/commands",
                          "app/controllers",
                          "app/models",
                          "app/libraries",
                          "app/database/migrations",
                          "app/database/seeds",
                          "app/tests/TestCase.php"
                      ]
                      ,
                      "psr-0": {
                           "Myapp": "app/libraries"
                      }
                  },
                  

                  这篇关于如何在 laravel 4 中自动加载“库"?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                  相关文档推荐

                  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 的问题)
                1. <small id='C6uPP'></small><noframes id='C6uPP'>

                  <legend id='C6uPP'><style id='C6uPP'><dir id='C6uPP'><q id='C6uPP'></q></dir></style></legend>

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

                        <tbody id='C6uPP'></tbody>

                          <tfoot id='C6uPP'></tfoot>
                            <bdo id='C6uPP'></bdo><ul id='C6uPP'></ul>