在Laravel中将自定义/新类文件放在哪里? [英] Where to put custom/new class file in Laravel?
问题描述
我有一个有关如何使用Yelp Fusion API的PHP示例.它使用 OAuth.php
文件有几个班级.在主要示例中,它是通过
I have PHP example on how to use Yelp Fusion API. It uses OAuth.php
file with several classes. In main example it is imported with
require_once('lib/OAuth.php');
我可以在Laravel中做同样的事情吗?
Can I do the same in Laravel?
还是我最好为OAuth.php
文件提供名称空间并将其放在树上的某个位置?放在哪里?
Or I'd better provide namespace for OAuth.php
file and put it somewhere on the tree? Where to put it?
推荐答案
您可以将Yelp Fusion API与其他任何OAuth实现一起使用. 以下是针对作曲家的OAuth软件包: https://packagist.org/search/?q=oauth
You can use Yelp Fusion API with any other OAuth implementation. Here are OAuth packages for composer: https://packagist.org/search/?q=oauth
使用软件包而不是自定义PHP文件将有助于保持项目的清洁.
Using packages instead of custom PHP files would help to keep project clean.
如果您仍然需要添加任何自定义PHP文件,只需在/app
中创建一个目录,例如库"或助手",或者更适合您的内容的目录.
If you still need to add any custom PHP files just create a directory within /app
like "Libraries" or "Helpers" or what fits better to your content.
/app
目录中的目录和文件由Composer自动加载.
Directories and files within /app
directory loaded automatically by Composer.
这篇关于在Laravel中将自定义/新类文件放在哪里?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!