Laravel文件夹结构 [英] Laravel folder structures

查看:99
本文介绍了Laravel文件夹结构的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在决定将文件夹放置到app\文件夹中的资源的位置时,经常会发现我有问题.

Often i come find it problematic when deciding where to place folders to resources within the app\ folder.

我应该在哪里放置诸如model observersvalidators以及form macrosrepositories ...的东西.目前,我正在执行以下操作

Where should i place things such as model observers and validators and form macros and repositories.... currently i do the following

\app
   \models
   \controllers
   \repositories
   \observers
   \interfaces
   \validators 
   \views

尽管我看到有些人在做以下事情:

although i see some people do the following:

\app
   \models
   \controllers
   \views
   \YourAppNameHere
      \Services
         \validators
         \...

我不理解\ Acme文件夹与实际应用程序相同时的原因吗?

I do not understand the reason behind the \Acme folder when its the same as the actual application?

推荐答案

掌握Laravel文件夹结构的最佳方法是将 app 目录视为 框架的前端.如果您查看 git仓库,您会发现它们是分开的-您可以克隆核心库,然后可以单独克隆laravel应用程序.应用程序及其子文件夹仅表示使用框架的一种方法.当然,它是根据最佳实践来设计的.还请检查核心框架 tests 目录-Laravel开发人员将库视为无头"-无需应用程序.对我来说,这是我掌握Laravel所需的一切.

Best way to master Laravel folder structure is to treat app directory as a front end of framework. If you take a look at the git repository you'll see that they are separated - you can clone core library and you can clone laravel application alone. Application, with it's subfolders represents just one way in which framework can be used. Ofcourse, it is designed with best practices involved. Check out also core framework tests directory - there Laravel developers treated library as "headless" - without application. For me, it was everything I need to grasp Laravel.

因此,您可以自由地修改现有结构,但是请记住,某些更改要求您 composer dump-autoload -主要是由于名称空间.

So you are free to modify existing structure, but keep in mind that some changes require you to composer dump-autoload - mostly because of namespaces.

这篇关于Laravel文件夹结构的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆