mitydigital / statamic-feedamic

An Atom and RSS feed for Statamic 3, 4 and 5
https://docs.mity.com.au/feedamic
8 stars 9 forks source link

Target class [MityDigital\StatamicRssFeed\Http\Controllers\StatamicRssFeedController] does not exist. #5

Closed josephrlee closed 2 years ago

josephrlee commented 2 years ago

Just ran through the upgrade guide to v2, but I'm getting an error.

Here's a link to the error output: https://flareapp.io/share/dPboRWE7#F44

I have Statamic 3.3.10 installed

And Laravel 9.10

Here's a stacktrace:

[previous exception] [object] (ReflectionException(code: -1): Class \"MityDigital\\StatamicRssFeed\\Http\\Controllers\\StatamicRssFeedController\" does not exist at /Users/josephl/Sites/CRISTA/worldconcern-statamic/vendor/laravel/framework/src/Illuminate/Container/Container.php:875)
[stacktrace]
#0 /Users/josephl/Sites/CRISTA/worldconcern-statamic/vendor/laravel/framework/src/Illuminate/Container/Container.php(875): ReflectionClass->__construct('MityDigital\\\\Sta...')
#1 /Users/josephl/Sites/CRISTA/worldconcern-statamic/vendor/laravel/framework/src/Illuminate/Container/Container.php(756): Illuminate\\Container\\Container->build('MityDigital\\\\Sta...')
#2 /Users/josephl/Sites/CRISTA/worldconcern-statamic/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(855): Illuminate\\Container\\Container->resolve('MityDigital\\\\Sta...', Array, true)
#3 /Users/josephl/Sites/CRISTA/worldconcern-statamic/vendor/laravel/framework/src/Illuminate/Container/Container.php(692): Illuminate\\Foundation\\Application->resolve('MityDigital\\\\Sta...', Array)
#4 /Users/josephl/Sites/CRISTA/worldconcern-statamic/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(840): Illuminate\\Container\\Container->make('MityDigital\\\\Sta...', Array)
#5 /Users/josephl/Sites/CRISTA/worldconcern-statamic/vendor/laravel/framework/src/Illuminate/Routing/Route.php(275): Illuminate\\Foundation\\Application->make('MityDigital\\\\Sta...')
#6 /Users/josephl/Sites/CRISTA/worldconcern-statamic/vendor/laravel/framework/src/Illuminate/Routing/Route.php(1081): Illuminate\\Routing\\Route->getController()
#7 /Users/josephl/Sites/CRISTA/worldconcern-statamic/vendor/laravel/framework/src/Illuminate/Routing/Route.php(1024): Illuminate\\Routing\\Route->controllerMiddleware()
#8 /Users/josephl/Sites/CRISTA/worldconcern-statamic/vendor/laravel/framework/src/Illuminate/Routing/Router.php(737): Illuminate\\Routing\\Route->gatherMiddleware()
#9 /Users/josephl/Sites/CRISTA/worldconcern-statamic/vendor/laravel/framework/src/Illuminate/Routing/Router.php(719): Illuminate\\Routing\\Router->gatherRouteMiddleware(Object(Illuminate\\Routing\\Route))
#10 /Users/josephl/Sites/CRISTA/worldconcern-statamic/vendor/laravel/framework/src/Illuminate/Routing/Router.php(703): Illuminate\\Routing\\Router->runRouteWithinStack(Object(Illuminate\\Routing\\Route), Object(Illuminate\\Http\\Request))
#11 /Users/josephl/Sites/CRISTA/worldconcern-statamic/vendor/laravel/framework/src/Illuminate/Routing/Router.php(667): Illuminate\\Routing\\Router->runRoute(Object(Illuminate\\Http\\Request), Object(Illuminate\\Routing\\Route))
#12 /Users/josephl/Sites/CRISTA/worldconcern-statamic/vendor/laravel/framework/src/Illuminate/Routing/Router.php(656): Illuminate\\Routing\\Router->dispatchToRoute(Object(Illuminate\\Http\\Request))
#13 /Users/josephl/Sites/CRISTA/worldconcern-statamic/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(167): Illuminate\\Routing\\Router->dispatch(Object(Illuminate\\Http\\Request))
#14 /Users/josephl/Sites/CRISTA/worldconcern-statamic/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(141): Illuminate\\Foundation\\Http\\Kernel->Illuminate\\Foundation\\Http\\{closure}(Object(Illuminate\\Http\\Request))
#15 /Users/josephl/Sites/CRISTA/worldconcern-statamic/vendor/statamic/cms/src/Http/Middleware/DisableFloc.php(18): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#16 /Users/josephl/Sites/CRISTA/worldconcern-statamic/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(180): Statamic\\Http\\Middleware\\DisableFloc->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#17 /Users/josephl/Sites/CRISTA/worldconcern-statamic/vendor/statamic/cms/src/Http/Middleware/CheckMultisite.php(14): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#18 /Users/josephl/Sites/CRISTA/worldconcern-statamic/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(180): Statamic\\Http\\Middleware\\CheckMultisite->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#19 /Users/josephl/Sites/CRISTA/worldconcern-statamic/vendor/statamic/cms/src/Http/Middleware/CheckComposerJsonScripts.php(21): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#20 /Users/josephl/Sites/CRISTA/worldconcern-statamic/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(180): Statamic\\Http\\Middleware\\CheckComposerJsonScripts->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#21 /Users/josephl/Sites/CRISTA/worldconcern-statamic/vendor/statamic/cms/src/Http/Middleware/PoweredByHeader.php(19): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#22 /Users/josephl/Sites/CRISTA/worldconcern-statamic/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(180): Statamic\\Http\\Middleware\\PoweredByHeader->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#23 /Users/josephl/Sites/CRISTA/worldconcern-statamic/vendor/barryvdh/laravel-debugbar/src/Middleware/InjectDebugbar.php(60): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#24 /Users/josephl/Sites/CRISTA/worldconcern-statamic/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(180): Barryvdh\\Debugbar\\Middleware\\InjectDebugbar->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#25 /Users/josephl/Sites/CRISTA/worldconcern-statamic/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(21): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#26 /Users/josephl/Sites/CRISTA/worldconcern-statamic/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/ConvertEmptyStringsToNull.php(31): Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#27 /Users/josephl/Sites/CRISTA/worldconcern-statamic/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(180): Illuminate\\Foundation\\Http\\Middleware\\ConvertEmptyStringsToNull->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#28 /Users/josephl/Sites/CRISTA/worldconcern-statamic/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(21): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#29 /Users/josephl/Sites/CRISTA/worldconcern-statamic/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TrimStrings.php(40): Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#30 /Users/josephl/Sites/CRISTA/worldconcern-statamic/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(180): Illuminate\\Foundation\\Http\\Middleware\\TrimStrings->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#31 /Users/josephl/Sites/CRISTA/worldconcern-statamic/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/ValidatePostSize.php(27): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#32 /Users/josephl/Sites/CRISTA/worldconcern-statamic/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(180): Illuminate\\Foundation\\Http\\Middleware\\ValidatePostSize->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#33 /Users/josephl/Sites/CRISTA/worldconcern-statamic/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/PreventRequestsDuringMaintenance.php(86): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#34 /Users/josephl/Sites/CRISTA/worldconcern-statamic/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(180): Illuminate\\Foundation\\Http\\Middleware\\PreventRequestsDuringMaintenance->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#35 /Users/josephl/Sites/CRISTA/worldconcern-statamic/vendor/laravel/framework/src/Illuminate/Http/Middleware/HandleCors.php(49): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#36 /Users/josephl/Sites/CRISTA/worldconcern-statamic/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(180): Illuminate\\Http\\Middleware\\HandleCors->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#37 /Users/josephl/Sites/CRISTA/worldconcern-statamic/vendor/laravel/framework/src/Illuminate/Http/Middleware/TrustProxies.php(39): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#38 /Users/josephl/Sites/CRISTA/worldconcern-statamic/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(180): Illuminate\\Http\\Middleware\\TrustProxies->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#39 /Users/josephl/Sites/CRISTA/worldconcern-statamic/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(116): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#40 /Users/josephl/Sites/CRISTA/worldconcern-statamic/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(142): Illuminate\\Pipeline\\Pipeline->then(Object(Closure))
#41 /Users/josephl/Sites/CRISTA/worldconcern-statamic/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(111): Illuminate\\Foundation\\Http\\Kernel->sendRequestThroughRouter(Object(Illuminate\\Http\\Request))
#42 /Users/josephl/Sites/CRISTA/worldconcern-statamic/public/index.php(52): Illuminate\\Foundation\\Http\\Kernel->handle(Object(Illuminate\\Http\\Request))
#43 /Users/josephl/.composer/vendor/laravel/valet/server.php(234): require('/Users/josephl/...')
#44 {main}
"} 
martyf commented 2 years ago

That looks like it is trying to reference the old Controller name and namespace (StatamicRssFeed) - like its still trying to load the old package.

Did you run composer update after updating the composer.json file? And have you made sure that the old package is not listed at all?

Running composer update from v1.x to v2.0 removes the /vendor/mitydigital/statamic-rss-feed folder and replaces it with the /vendor/mitydigital/feedamic folder.

I can't replicate this myself following the steps of the upgrade guide - I update the composer file, update composer, rename the config and it all works as expected.

Let me know how you go, and if you have any other clues or code that can help resolve this.

josephrlee commented 2 years ago

@martyf, yup I went through the update process. I even deleted the entire vendor folder and composer. lock file and tried to run a fresh install.

The one thing that still referenced the old add-on was in an .antlers.json file.

{"packageName":"mitydigital\/statamic-rss-feed","tags":[{"sourceFile":"\/Users\/josephl\/Sites\/CRISTA\/worldconcern-statamic\/vendor\/mitydigital\/statamic-rss-feed\/src\/ServiceProvider.php","handle":"service_provider","name":"boot","compound":"service_provider:boot","showInCompletions":true,"parameters":[]},{"sourceFile":"\/Users\/josephl\/Sites\/CRISTA\/worldconcern-statamic\/vendor\/mitydigital\/statamic-rss-feed\/src\/Tags\/RssAutoDiscovery.php","handle":"rss_auto_discovery","name":"rss_auto_discovery","compound":"rss_auto_discovery","showInCompletions":true,"parameters":[]}],"modifiers":[],"augmentContributions":[],"queryScopes":[],"viewModels":[]}

martyf commented 2 years ago

A google showed that antlers.json comes from the Antlers Toolbox for VS Code, does that sound right to you?

I'm not a VS Code user so don't have experience with this.

Is there something you need to do that will refresh this file based on what's installed?

josephrlee commented 2 years ago

Ahh, that makes sense. Yes, I do use that extension, but I don't think it has any bearing on the error. Just tried uninstalling and reinstalling it.

martyf commented 2 years ago

How strange. What does your composer.json file look like?

josephrlee commented 2 years ago
{
    "name": "statamic/statamic",
    "description": "Statamic",
    "keywords": [
        "statamic",
        "cms",
        "flat file",
        "laravel"
    ],
    "type": "project",
    "require": {
        "php": "^7.3 || ^8.0",
        "doublethreedigital/duplicator": "^2.1",
        "guzzlehttp/guzzle": "^7.2",
        "laravel/framework": "^9.10",
        "laravel/tinker": "^2.7",
        "league/flysystem-aws-s3-v3": "^3.0",
        "mitydigital/feedamic": "^2.0",
        "rias/statamic-redirect": "^2.1.1",
        "spatie/statamic-responsive-images": "^2.11.0",
        "statamic/cms": "3.3.10",
        "statamic/seo-pro": "3.1.0",
        "visuellverstehen/statamic-classify": "^2.3"
    },
    "require-dev": {
        "barryvdh/laravel-debugbar": "^3.6",
        "fakerphp/faker": "^1.9.1",
        "mockery/mockery": "^1.4.4",
        "nunomaduro/collision": "^6.1",
        "phpunit/phpunit": "^9.5.10",
        "spatie/laravel-ignition": "^1.2"
    },
    "config": {
        "optimize-autoloader": true,
        "preferred-install": "dist",
        "sort-packages": true,
        "allow-plugins": {
            "composer/package-versions-deprecated": true,
            "pixelfear/composer-dist-plugin": true
        }
    },
    "extra": {
        "laravel": {
            "dont-discover": []
        }
    },
    "autoload": {
        "psr-4": {
            "App\\": "app/",
            "Database\\Factories\\": "database/factories/",
            "Database\\Seeders\\": "database/seeders/"
        }
    },
    "autoload-dev": {
        "psr-4": {
            "Tests\\": "tests/"
        }
    },
    "minimum-stability": "dev",
    "prefer-stable": true,
    "scripts": {
        "pre-update-cmd": [
            "Statamic\\Console\\Composer\\Scripts::preUpdateCmd"
        ],
        "post-autoload-dump": [
            "Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
            "@php artisan package:discover --ansi",
            "@php artisan statamic:install --ansi"
        ],
        "post-root-package-install": [
            "@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
        ],
        "post-create-project-cmd": [
            "@php artisan key:generate --ansi"
        ],
        "post-update-cmd": [
            "@php artisan vendor:publish --tag=laravel-assets --ansi --force"
        ]
    }
}
martyf commented 2 years ago

Does this happen when accessing any URL, i.e. even an entry? Or just the feed?

If other pages (like an entry) are working, and you're using the {{ feedamic }} tag, do you see the RSS/Atom paths in your page source? In other words, is the Feedamic tag working?

Just for fun, remove Feedamic (composer remove mitydigital/feedamic), and try to access one of your feed URLs - do you get a 404, or does it try to load something?

I've done an install based on your composer.json, and besides needing to install the Cors package, had no issues - install, copy config (so I can set the "pages" collection) and then the feed URLs are loading.

josephrlee commented 2 years ago

Nope, just happens when I try to go /feed

The {{ feedamic }} tag is working, here's a screenshot of the homepage source:

Screen Shot 2022-05-04 at 3 18 43 PM

I ran the composer remove command and I still get the same error on the /feed url.

Here's my feedamic.php config file if that helps:


return [

    /*
    |--------------------------------------------------------------------------
    | Routes
    |--------------------------------------------------------------------------
    |
    | Ability to define Atom and RSS feed routes.
    |
    | The key is the feed type, and the value is the route.
    |
    | By default, an atom and RSS 2.0 feed will be generated.
    |
    | Remove from the array to disable a specific feed type.
    |
    */

    'routes' => [
        'atom' => '/feed/atom',
        'rss'  => '/feed'
    ],

    /*
    |--------------------------------------------------------------------------
    | Collections
    |--------------------------------------------------------------------------
    |
    | An array of collections to include in the feed.
    |
    */

    'collections' => [
        'villages',
        'pages',
        'donation_pages',
        'press_release'
    ],

    /*
    |--------------------------------------------------------------------------
    | Cache Key
    |--------------------------------------------------------------------------
    |
    | The base cache key for output. Will be cached forever until EventSaved is fired.
    |
    */

    'cache' => 'statamic-xml-sitemap',

    /*
    |--------------------------------------------------------------------------
    | Title
    |--------------------------------------------------------------------------
    |
    | The title for the feed
    |
    */

    'title' => 'World Cocnern',

    /*
    |--------------------------------------------------------------------------
    | Description
    |--------------------------------------------------------------------------
    |
    | The description (RSS) or subtitle (Atom) for the feed
    |
    */

    'description' => 'World Concern RSS feed.',

    /*
    |--------------------------------------------------------------------------
    | Summary
    |--------------------------------------------------------------------------
    |
    | A list of blueprint fields to look at to try to build the "summary" for the feed.
    |
    | This is ordered - the first field will be looked first, then the second, etc.
    |
    | When content is found, it will be used, and other fields will be ignored.
    |
    */

    'summary' => [
        'description',
        'banner_copy'
    ],

    /*
    |--------------------------------------------------------------------------
    | Image
    |--------------------------------------------------------------------------
    |
    | Configuration options for the image to be injected in to the "summary" for the entry.
    |
    | This only applies when Summary is being used.
    |
    | The Fields behave like summary - a cascading list of image fields to look at. You can specify the width
    | and height too to use for the image generation. If omitted, will be 1280 x 720.
    |
    | Disable this by setting to false.
    |
    */

    'image' => [
        'fields' => [
            'banner_image_seo'
        ],
        'width'  => 1280,
        'height' => 720
    ],

    /*
    |--------------------------------------------------------------------------
    | Author
    |--------------------------------------------------------------------------
    |
    | Sets the lookup of an author field.
    |
    | Set to "false" to disable looking for author details.
    |
    | If used,
    |   "handle" defines the blueprint reference to the author, a Statamic user
    |   "email", when true, will output the <email> for atom feeds
    |   "name", a pattern to use to build the name output
    |
    | For "name", each handle is in square brackets, and is used to concatenate fields if you are using
    | or want to customise the name output. For example, "[name_first] [name_last]" would pick "name_first"
    | and "name_last" from the User.
    |
    */

    'author' => [
        'handle' => 'author',

        // true to include the email in the feed, false to exclude - atom only
        'email'  => false,

        // the name pattern to use for the author name
        'name'   => '[name]',
    ],

    /*
    |--------------------------------------------------------------------------
    | Copyright
    |--------------------------------------------------------------------------
    |
    | A string to output to the <copyright> (RSS) or <rights> (Atom) feed.
    |
    | False will exclude this element.
    |
    */

    'copyright' => false,

    /*
    |--------------------------------------------------------------------------
    | Language
    |--------------------------------------------------------------------------
    |
    | Marks the feed as being in a specific language.
    |
    | As Atom, using xml:lang, can use more language definitions than the RSS specification, refer to the
    | RSS specification for suitable codes:
    |   https://www.rssboard.org/rss-language-codes
    |
    */

    'language' => 'en'
];
martyf commented 2 years ago

Does php artisan route:list show the feed and feed/atom routes?

If so, is it looking at the Feedamic package and controller? Or the StatamicRssFeed package?

image
josephrlee commented 2 years ago

Hmm, it gives me an error message:



   Illuminate\Contracts\Container\BindingResolutionException 

  Target class [Parfaitementweb\StatamicPodcastPublisher\Http\Controllers\PodcastController] does not exist.

  at vendor/laravel/framework/src/Illuminate/Container/Container.php:877
    873▕ 
    874▕         try {
    875▕             $reflector = new ReflectionClass($concrete);
    876▕         } catch (ReflectionException $e) {
  ➜ 877▕             throw new BindingResolutionException("Target class [$concrete] does not exist.", 0, $e);
    878▕         }
    879▕ 
    880▕         // If the type is not instantiable, the developer is attempting to resolve
    881▕         // an abstract type such as an Interface or Abstract Class and there is

  1   [internal]:0
      Illuminate\Foundation\Console\RouteListCommand::Illuminate\Foundation\Console\{closure}(Object(Illuminate\Routing\Route))

      +13 vendor frames 
  15  [internal]:0
      Illuminate\Foundation\Console\RouteListCommand::Illuminate\Foundation\Console\{closure}(Object(Illuminate\Routing\Route))```
josephrlee commented 2 years ago

Ohhh, I think this might be related to trying to install a previous add-on called: Parfaitementweb\StatamicPodcastPublisher

Which also did some feed stuff.

martyf commented 2 years ago

Maybe it override a route path somewhere, or there are remnants in your project?

josephrlee commented 2 years ago

Yes, I just tried clearing my route cache by runing: php artisan route:cache and now it all works!! Thanks for being so responsive!

martyf commented 2 years ago

Woohoo! No worries at all - timezone probably is working in your favour (and get started early these days). Glad it's all working now 👍

josephrlee commented 2 years ago

Also, in the super off chance someone else runs into this issue, it'd be helpful to add to the docs a note to clear the route cache.

martyf commented 2 years ago

Done, thanks: added a note about caching... although just about your earlier comment, if you're working locally maybe try php artisan route:clear and not cache them during dev? I only use route:cache on production.

josephrlee commented 2 years ago

Oh cool, I'm pretty new to working with Laravel, so thanks for the tip/feedback!

martyf commented 2 years ago

No stress - leaving caching disabled locally (routes, config, etc) is good for development - otherwise you have some odd head scratching debugging moments. But on production, cache away!