Routing works locally, but not remotely, unless path is written differently

37 views
Skip to first unread message

Alexandre Plennevaux

unread,
Aug 11, 2017, 8:12:13 AM8/11/17
to f3-fra...@googlegroups.com
using F3 v 3.6.

Locally, all my routes work perfectly, but on the remote server, one specific route does not work: it returns 404. All other routes are fine.

PHP version: 7.0.15 in local environment.
PHP version: 7.0.20 in remote environment.

Here is the code:

index.php:

$f3->route('GET|POST @login: /login', 'Controller\Inside->login');
$f3
->route('GET @logout: /logout', 'Controller\Inside->logout');
$f3
->route('GET @start: /start', 'Controller\Inside->start');
$f3
->route('GET @external_sync: /sync', 'Controller\Inside->sync');
$f3
->route('GET @getbadges: /get-badges/@username', 'Controller\CodeAcademy->getBadges'); // returns 404
$f3
->run();


in controller/CodeAcademy.php



namespace Controller;


class CodeAcademy
{
   
public function getBadges(\Base $f3, $params)
   
{
        $username
= $f3->get('PARAMS.username');
        echo $username
. ': ' . rand(0, 25);
   
}
}




It appears if i write the callback function directly in the route definition (index.php), then it works. So I assume the mistake must be in the file organization, or the class naming or... .

I just found a solution: lowercasing "Controller" works!

$f3->route('GET @getbadges: /get-badges/@username', 'controller\CodeAcademy->getBadges');


Which is weird, because for the other routes, Controller is written with capital C. 
Why ?

xfra35

unread,
Aug 11, 2017, 11:14:49 AM8/11/17
to Fat-Free Framework
Sounds like a filename case issue. It could be that your local environment is case-insensitive (e.g Mac OS X) and that your remove environment is case-sensitive (Linux).

Be aware that, when you call Controller\CodeAcademy, the framework autoloader will search for a file named either Controller/CodeAcademy.php or controller/codeacademy.php (lowercase).

So renaming the "controller" folder to "Controller" should fix your issue.

Alexandre Plennevaux

unread,
Aug 11, 2017, 12:01:32 PM8/11/17
to xfra35 via Fat-Free Framework
Indeed, I'm on Mac OS X and the remote environment is Linux. So it makes sense. I still don't understand why it works for some routes and not others. 

--
-- You've received this message because you are subscribed to the Google Groups group. To post to this group, send an email to f3-fra...@googlegroups.com. To unsubscribe from this group, send an email to f3-framework+unsubscribe@googlegroups.com. For more options, visit this group at https://groups.google.com/d/forum/f3-framework?hl=en
---
You received this message because you are subscribed to a topic in the Google Groups "Fat-Free Framework" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/f3-framework/8oqfdUPiZtE/unsubscribe.
To unsubscribe from this group and all its topics, send an email to f3-framework+unsubscribe@googlegroups.com.
To post to this group, send email to f3-fra...@googlegroups.com.
Visit this group at https://groups.google.com/group/f3-framework.
To view this discussion on the web visit https://groups.google.com/d/msgid/f3-framework/634409e7-26bc-4fd5-8133-fea659535ed2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

xfra35

unread,
Aug 11, 2017, 3:21:34 PM8/11/17
to Fat-Free Framework
 I still don't understand why it works for some routes and not others

Probably for the same reason. If for example, you have:
  • controller/inside.php
  • controller/CodeAcademy.php
then the first one will be fetched but not the second, because the framework looks for a filename with either the same case as the class path or a full lowercase.

Alexandre Plennevaux

unread,
Aug 11, 2017, 3:32:40 PM8/11/17
to xfra35 via Fat-Free Framework
Thanks a lot!

--
-- You've received this message because you are subscribed to the Google Groups group. To post to this group, send an email to f3-fra...@googlegroups.com. To unsubscribe from this group, send an email to f3-framework+unsubscribe@googlegroups.com. For more options, visit this group at https://groups.google.com/d/forum/f3-framework?hl=en
---
You received this message because you are subscribed to a topic in the Google Groups "Fat-Free Framework" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/f3-framework/8oqfdUPiZtE/unsubscribe.
To unsubscribe from this group and all its topics, send an email to f3-framework+unsubscribe@googlegroups.com.
To post to this group, send email to f3-fra...@googlegroups.com.
Visit this group at https://groups.google.com/group/f3-framework.
Reply all
Reply to author
Forward
0 new messages