4

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');

Can I do the same in Laravel?

Or I'd better provide namespace for OAuth.php file and put it somewhere on the tree? Where to put it?

Dims
  • 47,675
  • 117
  • 331
  • 600
  • 2
    is about test, that looks like a custom library, so just create a Library folder inside the app folder and place the class there with the right name space – Jorge Y. C. Rodriguez Apr 07 '17 at 11:44

2 Answers2

3

I suggest your to make a new directory inside app and call it like "Classes" and store your OAuth.php as "/app/Classes/OAuth.php". Don't forget to put a namespace App\Classes; to top of this file.

Due to having several classes inside your file I suggest to rewrite this a bit and separate each class to file

arku
  • 1,687
  • 17
  • 16
3

You can use the Yelp Fusion API with any OAuth implementation. To simplify the process and maintain a clean project, you can use an OAuth package.

You can find a list of OAuth packages for composer here.

Using packages instead of custom PHP files would help to keep project clean.

If you do need to add any custom PHP files, it's recommended to create a directory within the /app directory for organization. A good directory name could be "Libraries" or "Helpers," depending on the type of content being stored.

Note that directories and files within the /app directory are automatically loaded by Composer.

Glorfindel
  • 21,988
  • 13
  • 81
  • 109
Nikolai Kiselev
  • 6,201
  • 2
  • 27
  • 37