Sober Controllers not loading (variables not defined php error)

Hi,

I am working a theme, all was fine until I did a composer update. And I start to get ‘undefined variables’ php error. Rest of the wordpress are working fine.

Looks like the Sober Controllers are not loaded.

I tried to the following but didn’t get it working:

  • switch theme in WP Admin(deactivate activate my theme)

  • clear the compiled templates

  • add to my-theme/resources/functions.php
    add_filter(‘sober/controller/path’, function () {
    return dirname(get_template_directory()) . ‘/app/resources’;
    });

  • reinstall vendor package
    remove my vendor folders and composer clear-cache and install the packages again.

    In wordpress folder
    $ composer install
    Loading composer repositories with package information
    Installing dependencies (including require-dev) from lock file
    Package operations: 24 installs, 0 updates, 0 removals
    - Installing composer/installers (v1.2.0): Downloading (100%)
    - Installing johnpbloch/wordpress-core-installer (1.0.0): Downloading (100%) - Installing vlucas/phpdotenv (v2.4.0): Downloading (100%)
    - Installing philippbaschke/acf-pro-installer (v1.0.2): Downloading (100%) - Installing igniteonline/wpm-pro-installer (1.0.4): Downloading (100%) - Installing advanced-custom-fields/advanced-custom-fields-pro (5.6.1): Downloading (100%)
    - Installing deliciousbrains/wp-migrate-db-pro (1.7.2): Downloading (100%) - Installing deliciousbrains/wp-migrate-db-pro-media-files (1.4.7): Downloading (100%)
    - Installing johnpbloch/wordpress-core (4.8.1): Downloading (100%)
    - Installing johnpbloch/wordpress (4.8.1): Downloading (100%)
    - Installing oscarotero/env (v1.1.0): Downloading (100%)
    - Installing roots/soil (3.7.3): Downloading (100%)
    - Installing roots/wp-password-bcrypt (1.0.0): Downloading (100%)
    - Installing wpackagist-plugin/ajax-load-more (3.3.1): Downloading (100%) - Installing wpackagist-plugin/cms-tree-page-view (1.4): Downloading (100%) - Installing wpackagist-plugin/custom-post-type-ui (1.5.6): Downloading (100%) - Installing wpackagist-plugin/ewww-image-optimizer (3.6.1):Downloading (100%) - Installing wpackagist-plugin/post-types-image-sizes (1.2):Downloading (100%) - Installing wpackagist-plugin/safe-redirect-manager (1.8): Downloading (100%) - Installing wpackagist-plugin/simple-image-sizes (3.1.1): Downloading (100%) - Installing wpackagist-plugin/white-label-cms (1.6.1): Downloading (100%) - Installing wpackagist-plugin/wp-retina-2x (5.2.0): Downloading (100%) - Installing squizlabs/php_codesniffer (2.9.1): Downloading (100%)
    - Installing wpackagist-plugin/query-monitor (2.17.0): Downloading (100%) Generating autoload files

    cd web/app/themes/my-theme/
    composer install

    Loading composer repositories with package information
    Installing dependencies (including require-dev) from lock file
    Package operations: 18 installs, 0 updates, 0 removals
    - Installing composer/installers (v1.5.0): Downloading (100%)
    - Installing doctrine/inflector (v1.2.0): Downloading (100%)
    - Installing paragonie/random_compat (v2.0.11): Downloading (100%)
    - Installing illuminate/contracts (v5.4.36): Downloading (100%)
    - Installing illuminate/support (v5.4.36): Downloading (100%)
    - Installing illuminate/config (v5.4.36): Downloading (100%)
    - Installing psr/log (1.0.2): Downloading (100%)
    - Installing symfony/debug (v3.4.2): Downloading (100%)
    - Installing symfony/finder (v3.4.2): Downloading (100%)
    - Installing illuminate/filesystem (v5.4.36): Downloading (100%)
    - Installing illuminate/container (v5.4.36): Downloading (100%)
    - Installing illuminate/events (v5.4.36): Downloading (100%)
    - Installing illuminate/view (v5.4.36): Downloading (100%)
    - Installing symfony/yaml (v3.4.2): Downloading (100%)
    - Installing hassankhan/config (0.10.0): Downloading (100%)
    - Installing brain/hierarchy (2.3.1): Downloading (100%)
    - Installing soberwp/controller (dev-master 93aa3cc): Cloning 93aa3ccd86 from cache
    - Installing squizlabs/php_codesniffer (2.9.1): Loading from cache
    paragonie/random_compat suggests installing ext-libsodium (Provides a modern crypto API that can be used to generate random bytes.)
    illuminate/support suggests installing symfony/process (Required to use the composer class (~3.2).)
    illuminate/support suggests installing symfony/var-dumper (Required to use the dd function (~3.2).)
    illuminate/filesystem suggests installing league/flysystem (Required to use the Flysystem local and FTP drivers (~1.0).)
    illuminate/filesystem suggests installing league/flysystem-aws-s3-v3 (Required to use the Flysystem S3 driver (~1.0).)
    illuminate/filesystem suggests installing league/flysystem-rackspace (Required to use the Flysystem Rackspace driver (~1.0).)
    symfony/yaml suggests installing symfony/console (For validating YAML files using the lint command)
    Generating autoload files

How do I check whether the Sober controllers are loaded and how to force them to be loaded?

I did print out dirname(get_template_directory()) . '/resources
which points to the correct folder with my App.php and other Controllers.
The blade template is no longer interpreted. Blade syntax shows up in the browser.

Next remove soberwp from the composer.json
did a composer update

which removes the soberwp package

followed the instructions on https://github.com/soberwp/controller
to do a
composer require soberwp/controller:9.0.0-beta.3

./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 4 installs, 0 updates, 0 removals

  • Installing brain/hierarchy (2.3.1): Downloading (100%)
  • Installing symfony/yaml (v3.4.2): Downloading (100%)
  • Installing hassankhan/config (0.10.0): Downloading (100%)
  • Installing soberwp/controller (9.0.0-beta.3): Downloading (100%)
    symfony/yaml suggests installing symfony/console (For validating YAML files using the lint command)
    Writing lock file
    Generating autoload files

Still not working.

Removed the add_filter(‘sober/controller/path’, from my functions.php, and it worked.

Anyone knows why?