fatfree-core icon indicating copy to clipboard operation
fatfree-core copied to clipboard

A bug fix

Open myaaghubi opened this issue 6 months ago • 3 comments

myaaghubi avatar Jun 21 '25 05:06 myaaghubi

Providing the trailing slash is intended, it's not a bug. It's also mentioned in the documentation: N.B.1: Like every F3 directory name, $dir must end with a trailing slash!

geniuswebtools avatar Jun 22 '25 23:06 geniuswebtools

Let's have the mapper

$db=new DB\Jig('db/data/',DB\Jig::FORMAT_JSON);
$user=new DB\Jig\Mapper($db,'users');
$user=new DB\Jig\Mapper($db,'categories');
...

For a path like test/dir/db, it will make dbs like dbusers, dbcategories, which is not the responsibility of the mapper to fix the issue The point is whether these small things should be fixed in (it is a bug) or out of the framework

myaaghubi avatar Jun 23 '25 10:06 myaaghubi

TLDR; I'm simply saying, it's not a bug, and F3 is functioning as intended.

Longer Version: I understand what you're saying, and you're right, it doesn't take much to make the code a little more developer friendly, however, the opinionated approach by F3 is clearly stated in the documentation, and we the developer MUST add the trailing slash any time we're working with the framework.

During the development stage of your app, when you realize you're Jig code is trying to access dbusers you need to correct the path to match what is expected by F3.

I'm working on a project with Jig now, and my DB reference is: $f3->set('DB', new \DB\Jig(__DIR__ . '/jig/'));

Calling the mapper is as simple as: $mapper = new \DB\Mapper\Jig($f3->get('DB'), 'user.json'); ... and I'm not having any issues.

geniuswebtools avatar Jun 23 '25 14:06 geniuswebtools