Routes.php ignored in cakephp 3.7.3?


#1

Hi,

i am trying to get into it by setting up a new webserver.
as far as i understood and i should use routes.php in the config to store default routes to specific pages.
I was wondering about 2 hours long why i allways get the wrong page (/ all time uses the home.ctp not accepting any change to this)
Finaly i recognized that the routes.php is not loaded in any way (even if i write a syntax error into it or delete it, the page keeps working like there was the default routes.php)

I checked if the file on the webserver realy gets changes and it does.

p.s. the help and tutorials on cake expect to understand the system without having any practice. There are many code snippets where for me it is not clear in which file it should get implemented so i really need some newbee help how to setup a basic page like creating a layout.


#2

try changing in config/app.php 'debug' => true, your routes are probably cached thats why you dont see any changes,

or in 'src/Application.php` you have:

            // Add routing middleware.
            // Routes collection cache enabled by default, to disable route caching
            // pass null as cacheConfig, example: `new RoutingMiddleware($this)`
            // you might want to disable this cache in case your routing is extremely simple
            ->add(new RoutingMiddleware($this, '_cake_routes_'));

#3

Thank you for the reply,

debuging is enabled (if i disable it, it tells me " Please replace src/Template/Pages/home.ctp with your own version or re-enable debug mode." - i changed it now several times)

currently there is not routes.php in the config folder at all - without any notice or error.

in the src/Application.php it looks pretty the same as this cake installation was downloaded 2 days ago at github (github-production-release-asset - as cakephp-3-7-3.zip).
i changed the php version from 7.1 to 7.3. As it is a shared server, i can only unzip the files, and change the .htaccess file.

I only deleted the folder “tests” and i created /src/Template/Pages/start.ctp - i wanted to keep home.ctp for debugging purpose and change the routing for / to

$routes->connect('/', ['controller' => 'Pages', 'action' => 'display', 'Start']);

but until now i only can see that it doen’t matter if /config/routes.php contains errors or exist at all - changes in the file does not affect anything. I still verify any time that the file on the ftp is really changed and yes it is and its in the right folder. Changes to the /config/app.php in the same folder are visible immediately. could there be any reason why cake might “know” another routes.php at a different place (even without caching as debug is enabled)? mysterious…


#4

i got it!

you are right it had something to do with caching.
but i needed to rename the /tmp folder that seems to be where the cache is and after i reloaded the page my (now again existing) routes.php was now used. (And cake recreates a new tmp folder, so i can delete the old now)