fat-free-framework

fat-free framework flush partial output

会有一股神秘感。 提交于 2019-12-08 08:45:22
问题 I'm writing some back-office web pages for maintenance of our systems. I'm using F3 I have one route with a long processing, divided in many subprocesses. I made one template per subprocess, this way: $f3->route('GET /someroute', function($f3) { dosomework(); echo template::instance()->render('template-job1.html'); dosomeotherwork(); echo template::instance()->render('template-job2.html'); } I would like that i get in browser partial output as it is ready (one template at time) but what i get

Fat Free Framework (F3): custom 404 page (and others errors)

断了今生、忘了曾经 提交于 2019-12-04 11:39:37
问题 How I can handle my 404 custom page (and possibly other errors)? I just tried in routing part to add GET /@codes /WebController->error Where my Class WebController handles error, and for 404 i solved (partially). In effect it works for http://mydomain.ext/itdoesntexists but if i recall a http://mydomain.ext/sub/maybe_another_sub/and_so_on/doesnt_exist My route (of course) doesn't work. Btw, with that route in every case it doesn't push 404 header (just a maniac-vision of things, i'm thinking

Fat Free Framework (F3): custom 404 page (and others errors)

孤者浪人 提交于 2019-12-03 08:10:46
How I can handle my 404 custom page (and possibly other errors)? I just tried in routing part to add GET /@codes /WebController->error Where my Class WebController handles error, and for 404 i solved (partially). In effect it works for http://mydomain.ext/itdoesntexists but if i recall a http://mydomain.ext/sub/maybe_another_sub/and_so_on/doesnt_exist My route (of course) doesn't work. Btw, with that route in every case it doesn't push 404 header (just a maniac-vision of things, i'm thinking to Google looking for a resources and it doesn't receive a "pure" 404). Thank you You don't have to

How do I loop through the mysql resultset in fatfree framework?

六眼飞鱼酱① 提交于 2019-12-01 01:06:36
I am new to the php fat-free framework, and I am trying figure out how to loop through my mysql query results, or better yet, get it as an associative array (for learning purposes only). What I did so far is while(!$users->dry()){ array_push($user_assoc,$users->cast()); $users->next(); } This works, but I was wondering if there is a better way of doing this? Also how do I setup a error handler? I mean how do I check if the query had any errors (i.e. fat-free equivalent of mysql_error() )? DB querying There are 3 variants to loop through db results: Without mapper: Execute a SQL query and fetch

fatfree SQL error handling

倾然丶 夕夏残阳落幕 提交于 2019-12-01 00:01:12
If, for whatever reason, there is an error in creation of an entry using the mapper I get an error. I'd like to do a custom notification and fail gracefully like so... try { $request->save(); } catch (Exception $e) { $this->utils->errorNotify($f3,'could not create a request entry',http_build_query($_POST)); return null; } is this possible with F3? \DB\SQL is a subclass of PDO so it can throw catchable PDO exceptions. Since these are disabled by default, you need to enable them first. This can be done in 2 different ways: at instantiation time, for all transactions: $db = new \DB\SQL($dsn,

fatfree SQL error handling

谁都会走 提交于 2019-11-30 18:31:14
问题 If, for whatever reason, there is an error in creation of an entry using the mapper I get an error. I'd like to do a custom notification and fail gracefully like so... try { $request->save(); } catch (Exception $e) { $this->utils->errorNotify($f3,'could not create a request entry',http_build_query($_POST)); return null; } is this possible with F3? 回答1: \DB\SQL is a subclass of PDO so it can throw catchable PDO exceptions. Since these are disabled by default, you need to enable them first.

Fat-Free-Framework global variables and functions

余生颓废 提交于 2019-11-29 07:04:30
I'm new to fat free framework and i'm a little bit confused about the global variables. $f3->route('GET /@page','display'); function display($f3) { echo 'I cannot object to an object' . $f3->get('PARAMS.page'); }; $f3->run(); Here i'm using GET /@page as a token for the url route. In the function i then use $f3->get('PARAMS.page') to get the value of that variable. Since $f3->get is the method to get a global variable, why do i have to pass the $f3 class to the function. The below code doesn't work ($f3 class not passed to the function). $f3->route('GET /@page','display'); function display() {

Implementing namespaces in fatfree framework

 ̄綄美尐妖づ 提交于 2019-11-27 04:50:16
问题 I am trying to use namespaces in fatfree framework, but somehow its not able to find the class following is my setup routes.ini [routes] GET /=Src\Controllers\Index->index index.php namespace Src\Controllers; class Index { function index($f3) { $f3->set('name','world'); echo View::instance()->render('template.htm'); } } Global index.php // Retrieve instance of the framework $f3=require('lib/base.php'); // Initialize CMS $f3->config('config/config.ini'); // Define routes $f3->config('config