定制服务提供商的silex文件结构 [英] silex file structure for custom service providers

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

问题描述

我正在研究一个Silex项目,该项目需要编写一些自定义服务提供商及其相关类.

I am working on a Silex project which requires some custom service providers and their related classes to be written.

我知道了silex项目的首选文件结构,但无法在任何地方找到有关自定义类应适合该结构的信息.所有composer提供的库都自然位于供应商文件夹中,自定义库在哪里?

I am aware of the preferred file structure of silex projects but cannot anywhere find information on where custom classes should fit into this structure. All composer supplied libraries are naturally in the vendor folder, where do custom ones go?

此刻(缩小空间),我的目录结构如下:

At the moment (trimmed down for space) my directory structure follows:

.
├── composer.json
├── composer.lock
├── composer.phar
├── src
│   └── Dashboard
│       ├── Controller
│       │   ├── indexController.php
│       │   └── viewController.php
│       └── Model
│           └── Users.php
├── vendor
│   ├── autoload.php
│   ├── composer
├── views
│   ├── index.twig
│   ├── layout.twig
│   ├── logout.twig
│   └── view.twig
└── web
    ├── css
    │   ├── bootstrap.min.css
    │   └── style.css
    ├── index.php
    ├── js
    │   ├── bootstrap.min.js
    │   ├── jquery-2.0.3.min.js
    │   ├── jquery-ui-1.10.3.min.js
    └── twiglib.php

自定义服务提供商在何处使用自定义非作曲者提供的库?在src下有特定的命名空间?还是在供应商文件夹中?

Where in this do custom service providers go and custom non composer included libraries? In src under a specific namespace? Or in the vendor folder?

我可以从哪里看到建议在我的Silex应用中使用第三方服务提供商,而不是在供应商文件夹中,但是然后在Silex中创建新的服务提供商与此矛盾,并建议不要编辑vendor文件夹并将其放在src文件夹中.

I can see from Where to put 3rd party service providers in my Silex app than the vendor folder is suggested, but then Creating new service providers in Silex, contradicts this and advises against editing the vendor folder and putting it in the src folder.

有官方标准吗?

推荐答案

供应商文件夹应该只包含composer依赖项,因此肯定有一个不好的设计,那就是在其中手动添加一些特定的类.您可以将自定义服务提供程序放入单独的git存储库中,并通过composer在项目中使用它们.或者,如果这种方法太难用了,则可以将它们放在src文件夹中,在这种情况下,它可以是单独的文件夹Services,或者,如果您更喜欢域驱动的设计,则可以将每个服务提供商都放入特定于域的文件夹中(即,在您的情况下,它可能像/src/Dashboard/DashboardService.php).不确定是否存在任何通用标准.

Vendor folder is supposed to contain only composer dependencies, so it is for sure a bad design to add some specific classes there manually. You can put your custom Service providers into separate git repositories and use them in your project via composer. Or, if this way too hard to come, you could put them into your src folder, in this case it either could be a separate folder Services or, if you prefer domain driven design, you can put every service provider into your domain specific folders (i.e. in your case it could be smth like /src/Dashboard/DashboardService.php). Not sure if any common standard exists.

这篇关于定制服务提供商的silex文件结构的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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