dongwei8440
2014-05-31 11:39
采纳率: 100%
浏览 46
已采纳

在Laravel 4中自动加载php文件

I have a library called macro that I want to include in my project. I want to autoload all the files in the folder lib:

app
| ...
| lib
| | macro
| | | Search.php
| | | SearchFacade.php
| | | SearchServiceProvider.php
| | otherlib
| | | ...
| | lib4
| ...
| filters.php
| routes.php 

What do I need to do to autoload all the files in the folder lib, I am using Xampp, and I am running Windows 8.

Is it also possible to include in that folder a few standard stylesheets and javascript scripts?

图片转代码服务由CSDN问答提供 功能建议

我有一个名为 macro 的库,我希望将其包含在我的项目中。 我想自动加载 lib 文件夹中的所有文件:

  app 
 |  ... \ N |  LIB \ N |  | 宏\ N |  |  |  search.php中\ N |  |  |  SearchFacade.php \ N |  |  |  SearchServiceProvider.php \ N |  |  otherlib \ N |  |  |  ... \ N |  |  LIB4 \ N |  ... \ N |  filters.php \ N |  routes.php 
   
 
 

我需要做什么才能自动加载文件夹lib中的所有文件,我正在使用 Xampp ,我正在运行 Windows 8

是否也可以在该文件夹中包含一些标准样式表 javascript脚本

  • 写回答
  • 好问题 提建议
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • douwei2713 2014-05-31 13:02
    已采纳

    Change the autoload section in your composer.json and add app/lib to it

    autoload": {
            "classmap": [
                "app/commands",
                "app/controllers",
                "app/models",
                "app/database/migrations",
                "app/database/seeds",
                "app/tests/TestCase.php",
                "app/lib",
            ],
    

    Then just run composer dump-autoload in the command line to update the autoloader.

    已采纳该答案
    评论
    解决 无用
    打赏 举报

相关推荐 更多相似问题