Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Module routes config issue in 1.8.2
  • We have an issue with module routes in the 1.8.2 version of fuel/core.

    This is the routes config we use in 1.8.1 which does not work in 1.8.2;

    app/config/config.php
        'always_load' => array(
            'config' => array(
                'testmodule::routes' => 'routes',
                'routes',
            ),
        ),

    app/modules/testmodule/config/routes.php
        'admin' => 'testmodule/admin',

    So, in 1.8.1 hitting /admin in the browser goes to the expected place, but after updating fuel/core to 1.8.2 we get a 404.

    The reason for this 'issue' is that you have changed the order that loads in "routes" config and the "always load" configs.

    In core/classes/fuel.php:

    1.8.1, rows 192-199:
        \Event::register('fuel-shutdown', 'Fuel::finish'); // this doesn't have anything to do with this issue

        // Always load classes, config & language set in always_load.php config
        static::always_load();

        // Load in the routes
        \Config::load('routes', true);
        \Router::add(\Config::get('routes'));

    1.8.2, rows 189-196:
        // Load in the routes
        \Config::load('routes', true);
        \Router::add(\Config::get('routes'));

        \Event::register('fuel-shutdown', 'Fuel::finish'); // this doesn't have anything to do with this issue

        // Always load classes, config & language set in always_load.php config
        static::always_load();

    So, our question is, are we wrong to load routes as we have been doing and if so how should it be done?

  • Yes, you define routes in routes.php, not in config.php.
  • Um, no, that's not what we're doing at all. We are defining routes in our module, and loading it in from the app config.
  • Even it they are module routes, they still go in routes.php, in this case in your module's config directory.
  • That’s what i am trying to say: in 1.8.2, even when placed in the module’s route config, it does not work. Previously in 1.8.1 it did. Now it does not unless we revert the loader code to 1.8.1’s version. All I'm doing with config.php is always_loading them. 
  • You don't need to "always load" routes, routes are automaticly loaded when needed, the app routes always (see row 190), the module routes when needed.

    If you have none-module routes in a module routes.php config file, you've misused the system.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion