oscarotero / Embed

Get info from any web service or page
MIT License
2.09k stars 312 forks source link

Class Embed\Embed not found #39

Closed soullivaneuh closed 9 years ago

soullivaneuh commented 9 years ago

I try to use your library from a standard symfony project and I get this error:

PHP Fatal error:  Class 'Embed\Embed' not found in /home/sullivan/projects/ddn/src/AppBundle/Manager/PressSourceManager.php on line 104
PHP Stack trace:
PHP   1. {main}() /home/sullivan/projects/ddn/app/console:0
PHP   2. Symfony\Component\Console\Application->run() /home/sullivan/projects/ddn/app/console:27
PHP   3. Symfony\Bundle\FrameworkBundle\Console\Application->doRun() /home/sullivan/projects/ddn/vendor/symfony/symfony/src/Symfony/Component/Console/Application.php:126
PHP   4. Symfony\Component\Console\Application->doRun() /home/sullivan/projects/ddn/vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Console/Application.php:96
PHP   5. Symfony\Component\Console\Application->doRunCommand() /home/sullivan/projects/ddn/vendor/symfony/symfony/src/Symfony/Component/Console/Application.php:195
PHP   6. Symfony\Component\Console\Command\Command->run() /home/sullivan/projects/ddn/vendor/symfony/symfony/src/Symfony/Component/Console/Application.php:882
PHP   7. AppBundle\Command\PressFetchCommand->execute() /home/sullivan/projects/ddn/vendor/symfony/symfony/src/Symfony/Component/Console/Command/Command.php:252
PHP   8. AppBundle\Manager\PressSourceManager->refreshSource() /home/sullivan/projects/ddn/src/AppBundle/Command/PressFetchCommand.php:32
PHP   9. AppBundle\Manager\PressSourceManager->generateArticleFromItem() /home/sullivan/projects/ddn/src/AppBundle/Manager/PressSourceManager.php:60

Fatal error: Class 'Embed\Embed' not found in /home/sullivan/projects/ddn/src/AppBundle/Manager/PressSourceManager.php on line 104

Call Stack:
    0.0001     240208   1. {main}() /home/sullivan/projects/ddn/app/console:0
    0.0264    3318376   2. Symfony\Component\Console\Application->run() /home/sullivan/projects/ddn/app/console:27
    0.0288    3521488   3. Symfony\Bundle\FrameworkBundle\Console\Application->doRun() /home/sullivan/projects/ddn/vendor/symfony/symfony/src/Symfony/Component/Console/Application.php:126
    0.1865   15620192   4. Symfony\Component\Console\Application->doRun() /home/sullivan/projects/ddn/vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Console/Application.php:96
    0.1867   15621112   5. Symfony\Component\Console\Application->doRunCommand() /home/sullivan/projects/ddn/vendor/symfony/symfony/src/Symfony/Component/Console/Application.php:195
    0.1932   15812784   6. Symfony\Component\Console\Command\Command->run() /home/sullivan/projects/ddn/vendor/symfony/symfony/src/Symfony/Component/Console/Application.php:882
    0.1934   15817176   7. AppBundle\Command\PressFetchCommand->execute() /home/sullivan/projects/ddn/vendor/symfony/symfony/src/Symfony/Component/Console/Command/Command.php:252
    0.3071   24171424   8. AppBundle\Manager\PressSourceManager->refreshSource() /home/sullivan/projects/ddn/src/AppBundle/Command/PressFetchCommand.php:32
    1.1834   24244152   9. AppBundle\Manager\PressSourceManager->generateArticleFromItem() /home/sullivan/projects/ddn/src/AppBundle/Manager/PressSourceManager.php:60

  [Symfony\Component\Debug\Exception\ClassNotFoundException]                                
  Attempted to load class "Embed" from namespace "Embed".                                   
  Did you forget a "use" statement for e.g. "Twig_Node_Embed" or "Twig_TokenParser_Embed"?  

I think it's an auto-load error after comparing between your installed package and an another:

$ composer show embed/embed
name     : embed/embed                                                                       
descrip. : PHP library to retrieve page info using oembed, opengraph, etc
keywords : embed, embedly, oembed, opengraph, twitter cards
versions : dev-master, * v1.8.0, v1.7.0, v1.6.0, v1.5.9, v1.5.8, v1.5.7, v1.5.6, v1.5.5, v1.5.4, v1.5.3, v1.5.2, v1.5.1, v1.5.0, v1.4.6, v1.4.5, v1.4.4, v1.4.3, 1.4.2, v1.4.1, v1.4.0, v1.3.8, v1.3.7, v1.3.6, v1.3.5, v1.3.4, v1.3.3, v1.3.2, v1.3.1, v1.3.0, v1.2.1, v1.2.0, v1.1.1, v1.1.0, v1.0.2, v1.0.1, dev-changes, dev-custom_urls_resolvers
type     : library
license  : MIT
source   : [git] https://github.com/oscarotero/Embed.git 7a2720901652f5e2e3df9609648718573d60aae1
dist     : [zip] https://api.github.com/repos/oscarotero/Embed/zipball/7a2720901652f5e2e3df9609648718573d60aae1 7a2720901652f5e2e3df9609648718573d60aae1
names    : embed/embed

autoload
psr-0
Embed => .

requires
php >=5.3.0
$ composer show guzzlehttp/guzzle
name     : guzzlehttp/guzzle                                                                 
descrip. : Guzzle is a PHP HTTP client library and framework for building RESTful web service clients
keywords : client, curl, framework, http, http client, rest, web service
versions : dev-master, 5.0.x-dev, 5.0.3, 5.0.2, 5.0.1, 5.0.0, * 4.2.3, 4.2.2, 4.2.1, 4.2.0, 4.1.8, 4.1.7, 4.1.6, 4.1.5, 4.1.4, 4.1.3, 4.1.2, 4.1.1, 4.1.0, 4.0.2, 4.0.1, 4.0.0, 4.0.0-rc.2, 4.0.0-rc.1, v3.8.1, v3.8.0, v3.7.4, v3.7.3, v3.7.2, v3.7.1, v3.7.0, v3.6.0, v3.5.0, v3.4.3, v3.4.2, v3.4.1, v3.4.0, v3.3.1, v3.3.0, v3.2.0, v3.1.2, v3.1.1, v3.1.0, v3.0.7, v3.0.6, v3.0.5, v3.0.4, v3.0.3, v3.0.2, v3.0.1, v3.0.0, v2.8.8, v2.8.7, v2.8.6, v2.8.5, v2.8.4, v2.8.3, v2.8.2, v2.8.1, v2.8.0, v2.7.2, v2.7.1, v2.7.0, v2.6.6, v2.6.5, v2.6.4, v2.6.3, v2.6.2, v2.6.1, v2.6.0, v2.5.0, v2.4.1, v2.4.0, v2.3.2, v2.2.4, v2.2.3, v2.2.2, v2.2.1, v2.2.0, v2.1.4, v2.1.3, v2.1.2, v2.1.1, v2.1.0, v2.0.5, v2.0.4, v2.0.3, v2.0.2, v2.0.1, v2.0.0, v1.0.4, v1.0.3, dev-null_override
type     : library
license  : MIT
source   : [git] https://github.com/guzzle/guzzle.git 66fd916e9f9130bc22c51450476823391cb2f67c
dist     : [zip] https://api.github.com/repos/guzzle/guzzle/zipball/66fd916e9f9130bc22c51450476823391cb2f67c 66fd916e9f9130bc22c51450476823391cb2f67c
names    : guzzlehttp/guzzle

autoload
psr-4
GuzzleHttp\ => src/
files

As you can see, the autoload configuration is different. But I don't know if is relevant.

Here, an extract of my php code using your class:

use Embed\Embed;

// [...]
    private function generateArticleFromItem(Item $item)
    {
        $article = new PressArticle();
        $embed = Embed::create($articleUrl);
        $article->setIntroduction($embed->getDescription());

        return $article;
    }
// [...]

And my full composer.json file:

{
    "name": "ddn/ddn",
    "type": "project",
    "autoload": {
        "psr-0": { "": "src/", "SymfonyStandard": "app/" }
    },
    "repositories": [
        {
            "type": "vcs",
            "url": "https://github.com/Soullivaneuh/SonataDoctrineORMAdminBundle.git"
        }
    ],
    "require": {
        "php": ">=5.3.3",
        "ext-gd": "*",
        "symfony/symfony": "2.6.*",
        "doctrine/orm": "~2.2,>=2.2.3",
        "doctrine/doctrine-bundle": "~1.2",
        "doctrine/mongodb-odm-bundle": "3.0.*",
        "doctrine/migrations" : "dev-master",
        "doctrine/doctrine-migrations-bundle": "dev-master",
        "stof/doctrine-extensions-bundle": "~1.1",
        "twig/extensions": "~1.1",
        "symfony/assetic-bundle": "~2.3",
        "symfony/swiftmailer-bundle": "~2.3",
        "symfony/monolog-bundle": "~2.4",
        "sensio/distribution-bundle": "~3.0",
        "sensio/framework-extra-bundle": "~3.0",
        "incenteev/composer-parameter-handler": "~2.0",
        "mopa/bootstrap-bundle": "3.x-dev",
        "knplabs/knp-paginator-bundle": "2.4.*",
        "knplabs/knp-menu-bundle": "2.0.*",
        "craue/formflow-bundle": "2.1.*",
        "friendsofsymfony/user-bundle": "2.0.x-dev",
        "friendsofsymfony/oauth-server-bundle": "1.4.*",
        "friendsofsymfony/rest-bundle": "1.4.*",
        "sonata-project/admin-bundle": "~2.3",
        "sonata-project/doctrine-orm-admin-bundle": "dev-list-builder-template",
        "sonata-project/intl-bundle": "~2.2",
        "jms/serializer-bundle": "~0.13",
        "ornicar/gravatar-bundle": "~1.1",
        "aferrandini/urlizer": "1.0.*",
        "guzzlehttp/guzzle": "~4.0",
        "vich/uploader-bundle": "~0.11",
        "gregwar/image-bundle": "~2.0",
        "kriswallsmith/spork": "~0.2",
        "inlinestyle/inlinestyle": "*",
        "debril/rss-atom-bundle": "~1.4",
        "fabpot/goutte": "~2.0",
        "embed/embed": "~1.8"
    },
    "require-dev": {
        "sonata-project/easy-extends-bundle": "~2.1",
        "sensio/generator-bundle": "~2.4",
        "squizlabs/php_codesniffer": "~1.5",
        "fabpot/php-cs-fixer": "*",
        "sebastian/phpcpd": "~2.0",
        "phpspec/phpspec": "~2.0",
        "henrikbjorn/phpspec-code-coverage": "~0.2",
        "behat/behat": "~3.0",
        "behat/symfony2-extension": "~2.0",
        "behat/mink-extension": "~2.0",
        "behat/mink-browserkit-driver": "~1.2"
    },
    "scripts": {
        "post-root-package-install": [
            "SymfonyStandard\\Composer::hookRootPackageInstall"
        ],
        "post-install-cmd": [
            "Incenteev\\ParameterHandler\\ScriptHandler::buildParameters",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::clearCache",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installAssets",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installRequirementsFile",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::removeSymfonyStandardFiles"
        ],
        "post-update-cmd": [
            "Incenteev\\ParameterHandler\\ScriptHandler::buildParameters",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::clearCache",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installAssets",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installRequirementsFile",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::removeSymfonyStandardFiles"
        ]
    },
    "config": {
        "bin-dir": "bin"
    },
    "minimum-stability": "dev",
    "prefer-stable": true,
    "extra": {
        "symfony-app-dir": "app",
        "symfony-web-dir": "web",
        "symfony-assets-install": "relative",
        "incenteev-parameters": {
            "file": "app/config/parameters.yml"
        },
        "branch-alias": {
            "dev-master": "2.6-dev"
        }
    }
}

Ask me if you want more information.

Thanks!

soullivaneuh commented 9 years ago

Thanks for the fix, could you please push a new stable tag for it? Thanks.

oscarotero commented 9 years ago

Yes, I see both fixed the issue at the same time :) Thank for your feedback, I've changed the psr-0 autoloader to psr-4 recently and forgot change the the composer.