在Laravel中包含一个非作曲家的PHP项目

I am trying to use this PHP project RecipeParser in a Laravel project. Aa far as I can tell, it can't be loaded with Composer. It doesn't have any Composer info in the readme, and I can't find it on Packagist either.

I've tried downloading the folder to my /App/ folder and adding it in the controler like this:

include app_path() . '/RecipeParser/bootstrap.php';

But it cannot be found.

I've tried adding the folder in composer like this:

"autoload": {
    "classmap": [
        "database",
        "app/RecipeParser"
    ],
....

and running composer dump-autoload but again it cannot be location.

I've tried adding:

use OneTsp\RecipeParser;

and many variations at the contoller, but doesn't help.

The code I am trying to call it with is

$recipe = RecipeParser::parse($html, $url);

Does it need to be added in config.app somewhere? Is there something specific about this pcakage which means it needs to be included differently? And is there a way to just load it directly from Github,so it gets updated, etc? Normally I can find these in Composer, is there a reason this package isn't?

many thanks

After some google, I found relayfoods/recipe-parser (composer based PHP library for parsing recipe data from HTML) same like you require.

Composer command: composer require relayfoods/recipe-parser Usage:

$recipe = RecipeParser::parse($html, $url);
print_r($recipe);

This should work for you.