dongzhi5587 2014-07-03 15:24
浏览 59
已采纳

Laravel 4中的包与CodeIgniter中的库相同吗?

I used to use CodeIgniter. In CodeIgniter whenever I had to create my own classes, I used to create a class in the library folder and used it as a library. In Laravel they use packages. In the documentation they also talk about creating your own packages. Are packages in Laravel 4 same as libraries in the CodeIgniter?

  • 写回答

2条回答 默认 最新

  • douzhanbai9526 2014-07-03 18:19
    关注

    What seems to be common now is to put custom classes, exceptions, validation, etc. into a folder that is named in correspondence to your application.

    For example:

    | laravel
    |    -- AppName/
    |       -- Exceptions
    |       -- Repositories
    |       -- Validation
    |       -- CustomClasses (your custom class name)
    |    -- controllers
    |    -- models
    |    -- views
    

    To include in composer, the easiest way is to include the classmap

    composer.json

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

    If you would like to use psr-4 auto loading instead, there is a great free video on Laracasts to get you started https://laracasts.com/lessons/psr-4-autoloading

    Also, if you're a Laracasts member, the Where Do I Put This video is exactly what you're looking for with this question. https://laracasts.com/lessons/where-do-i-put-this

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥20 基于MSP430f5529的MPU6050驱动,求出欧拉角
  • ¥20 Java-Oj-桌布的计算
  • ¥15 powerbuilder中的datawindow数据整合到新的DataWindow
  • ¥20 有人知道这种图怎么画吗?
  • ¥15 pyqt6如何引用qrc文件加载里面的的资源
  • ¥15 安卓JNI项目使用lua上的问题
  • ¥20 RL+GNN解决人员排班问题时梯度消失
  • ¥60 要数控稳压电源测试数据
  • ¥15 能帮我写下这个编程吗
  • ¥15 ikuai客户端l2tp协议链接报终止15信号和无法将p.p.p6转换为我的l2tp线路