Skip to content
This repository has been archived by the owner on Jul 10, 2023. It is now read-only.

Uncaught ReflectionException after composer update #55

Closed
YarGnawh opened this issue Oct 30, 2017 · 4 comments
Closed

Uncaught ReflectionException after composer update #55

YarGnawh opened this issue Oct 30, 2017 · 4 comments

Comments

@YarGnawh
Copy link

After running a composer update on my root sage theme

composer update
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 2 installs, 16 updates, 1 removal
  - Removing paragonie/random_compat (v2.0.10)
  - Updating symfony/yaml (v3.3.6 => v3.3.10) Loading from cache
  - Removing soberwp/controller (9.0.0-beta.4)
  - Installing soberwp/controller (dev-master 93aa3cc) Cloning 93aa3ccd86 from cache
  - Updating symfony/polyfill-mbstring (v1.5.0 => v1.6.0) Loading from cache
  - Updating symfony/translation (v3.3.6 => v3.3.10) Loading from cache
  - Installing psr/simple-cache (1.0.0) Loading from cache
  - Installing psr/container (1.0.0) Loading from cache
  - Updating illuminate/contracts (v5.4.27 => v5.5.17) Loading from cache
  - Updating illuminate/support (v5.4.27 => v5.5.17) Loading from cache
  - Updating illuminate/config (v5.4.27 => v5.5.17) Loading from cache
  - Updating symfony/debug (v3.3.6 => v3.3.10) Loading from cache
  - Updating symfony/finder (v3.3.6 => v3.3.10) Loading from cache
  - Updating illuminate/filesystem (v5.4.27 => v5.5.17) Loading from cache
  - Updating illuminate/container (v5.4.27 => v5.5.17) Loading from cache
  - Updating illuminate/events (v5.4.27 => v5.5.17) Loading from cache
  - Updating illuminate/view (v5.4.27 => v5.5.17) Loading from cache
  - Updating symfony/console (v3.3.6 => v3.3.10) Loading from cache
  - Updating illuminate/console (v5.4.27 => v5.5.17) Loading from cache
  - Updating symfony/process (v3.3.6 => v3.3.10) Loading from cache
Generating autoload files

The entire theme stopped working. In the error log it is output this error

[Mon Oct 30 16:05:49.409392 2017] [:error] [pid 1366] [client 172.17.0.1:43296] PHP Fatal error:  Uncaught ReflectionException: Class App\\Controllers\\template-home does not exist in /app/wp-content/themes/asdf/vendor/soberwp/controller/controller.php:19\nStack trace:\n#0 /app/wp-content/themes/asdf/vendor/soberwp/controller/controller.php(19): ReflectionClass->__construct('App\\\\Controllers...')\n#1 /app/wp/wp-includes/class-wp-hook.php(298): Sober\\Controller\\loader('')\n#2 /app/wp/wp-includes/class-wp-hook.php(323): WP_Hook->apply_filters(NULL, Array)\n#3 /app/wp/wp-includes/plugin.php(453): WP_Hook->do_action(Array)\n#4 /app/wp/wp-settings.php(448): do_action('init')\n#5 /app/wp-config.php(125): require_once('/app/wp/wp-sett...')\n#6 /app/wp/wp-load.php(42): require_once('/app/wp-config....')\n#7 /app/wp/wp-blog-header.php(13): require_once('/app/wp/wp-load...')\n#8 /app/index.php(4): require('/app/wp/wp-blog...')\n#9 {main}\n  thrown in /app/wp-content/themes/asdf/vendor/soberwp/controller/controller.php on line 19, referer: http://localhost:3000/about-us/

Any idea what's causing this?

@alwaysblank
Copy link

I ran into this problem because my controllers had
namespace App;
not
namespace App\Controllers;
For me, changing the namespace and making sure that the file names matched the class names (i.e. FrontPage.php for class FrontPage) solved this issue.

...Except in one case: The 404 template. I get the same reflection error, which I would fix in the same way...but it expects a class named 404, which PHP chokes on. I've tried shuffling the names around, but with no luck.

@rolandp
Copy link

rolandp commented Nov 20, 2017

Ran into the same problem after updating "roots/sage-lib": "~9.0.0-beta.3" to "roots/sage-lib": "~9.0.0-beta.4" and "soberwp/controller": "dev-master" (from commit e9358ff to commit 93aa3cc).

Changing the namespace declaration did not fix the problem though.

@webstractions
Copy link

@rolandp Check your composer.json file. It should be along the lines of:

"autoload": {
    "psr-4": {
      "App\\": "app/"
    }
  },
  "require": {
    "php": ">=7",
    "composer/installers": "~1.0",
    "illuminate/support": "~5.4",
    "roots/sage-lib": "~9.0.0-beta.4",
    "soberwp/controller": "~9.0.0-beta.4"
  },

@alwaysblank I kind of addressed how to get around this here #49 (comment) which should allow you to declare 404 templates.

@darrenjacoby
Copy link
Member

There is a difference between dev-master and beta.4. dev-master uses PSR4, so @alwaysblank is correct. The class names need to be PSR4 complaint and the namespace needs to be namespace App\Controllers;

@alwaysblank interesting note on the 404, I'm doing a template override option (which will also address underscores in filenames) so that will be the best workaround. I believe PSR4 loading is worth that caveat.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants