F3 Caveats
F3, https://fatfreeframework.com/, is a 'new style' (central router based) php web framework that is lightweight with just enough batteries included. It is similar in scope to Silex. I chose it because its architecture allows me to build from one page to model-view-controller webapps. It also has a nice Sinatra style convenience methods api and a TAL based templating language. I will use composer, php’s package mangager - https://getcomposer.org/, to add appropriate libraries.
Now, having said all that it’s documentation is pretty good. However, there are still parts that would need more clarifying for me. This page is a log of those parts and hopefully, how I solved the caveat. The content is in reverse chronological order.
Caveats
How does f3 handle folder and path name conflicts?
-
I created a get route and folder with the same name and tested using php’s built in webserver
-
I got an error message
-
when I changed the route name, the page displayed.
How do you save variables across sessions using f3’s dependency container?
-
hypothesis:
-
I think the examples are incorrect and you need to pass the app instance using a closure syntax
-
I think this might have affected my testing of its built in login prompt and ldap error handling
-
-
resolution:
-
you can’t save variables across sessions using f3’s dependency container
-
setting a variable in f3 will allow the variable to be accessed, as if they were called globally, within inner functions for that script
-
as the docs state, the variables will not persist across http requests
-
to persist variables across http requests, you must use 'session_start()' and save the value in the SESSION superglobal, either through f3 or php
-
using an anonymous function or closure gives the same results
-
if you pass the f3 instance as a reference to the closure it will WORK!
-
Built in ldap library does not have the same schema as my organization:
-
also, had to suppress php’s errors using @ldap_bind()
-
php docs, http://php.net/manual/en/function.ldap-bind.php, state ldap_bind returns true or false
-
but for some reason, it generates an error that even bypasses exception catching.
Reminder
How to reload composer.json:
-
go to the same folder as composer.json, then type:
-
composer dump-autoload
-
-
i.e. after manually adding a file based library, etc.
— MarlonAGriffith - 10 Aug 2016