bcosca / fatfree Goto Github PK
View Code? Open in Web Editor NEWA powerful yet easy-to-use PHP micro-framework designed to help you build dynamic and robust Web applications - fast!
A powerful yet easy-to-use PHP micro-framework designed to help you build dynamic and robust Web applications - fast!
In the latest build (git) query parameters are not set:
e.g.
for route defined as /search
and uri /search/?q=foo
q is not available in F3::get('GET.q'), nor $_GET['q'] superglobal.
In 2.0.10 build works as expected.
the good old known problem of dynamic template includes.
http://sourceforge.net/tracker/?func=detail&aid=3413985&group_id=288268&atid=1220992
you know: have a template with a repeat, which is containing that uses the key/values of the repeat method, and so on.
enhancement code at:
ikkez@b7c4da1
test case: http://pastebin.com/hn4mA3Dp
Using 2.0.10, localhost sessions don't work with Chrome: the cookie is not set. I made the following workaround at base.php, line 1731, $jar definition:
'domain'=>($_SERVER['SERVER_NAME']=='localhost')?'':'.'.$_SERVER['SERVER_NAME'],
since neither localhost nor .localhost worked at all as a domain using chrome.
setting Sessions and Cookies are using the JAR F3 var.
$jar=array(
'expire'=>0,
'path'=>$base?:'/',
'domain'=>'.'.$_SERVER['SERVER_NAME'],
'secure'=>($scheme=='https'),
'httponly'=>TRUE
);
if $_SERVER['SERVER_NAME']
returns an IP address, the response header contains Set-Cookie: domain=.192.168.0.5
and because of the leading dot =. the cookies is rejected by some browser.
i recommend to include a condition that check's that and only adds the . if it's really a host name, and not an address.
_
I am now the second person I am aware of who was unsure whether it was safe to use F3 in GPL-licensed commercial applications because the phrasing on the site implies that only academic and personal users are eligible for GPLv3 license terms.
See the comments on my "My impressions of Fat-Free Framework for PHP" post for the original text.
(Also, I could be wrong, but I think I remember reading that GPL is a trademark that's only licensed to you on the condition that you leave the license text unadulterated with "additional restrictions")
Both I and Alex feel that, if F3's terms really are "GPL or pay us to use it in closed-source code" in the same way MySQL is, the phrasing should be corrected to something like this:
Fat-Free Framework is licensed under the GNU GPLv3. Alternative licensing is available for a fee
should you not wish to release your own code under these terms.
Sorry for my bad english and sorry if someone already asked a similar question and got an answer
If you use f3-project in subdirectory there is a problem with the router
$app->route ('GET /', function () {/ * do something * /;});
is a permanent redirect to / and loops and i got "301 Moved Permanently" from server
I found where it is in file base.php Lines 1284-1289
in .htaccess i set
RewriteBase /subdir_name/
Hi,
I cannot get your image resizing to work (Graphics::thumb(F3::get('PARAMS[file]'),360,240);), so I think it might contain a bug. I get the same result as I see on the main page of Fat-Free (I see no images for Jane / Tarzan)
http://bcosca.github.com/fatfree/#plug-ins
Can you confirm if there are issues with the resizing or is it a local problem?
Regards,
Alex
while its a pain to make requests caseless via apache, there is an easy way to get your application work in a case insensitive manner related to the BASE-name.
just add the PCRE_CASELESS-Modificator at the first preg_replace in the run-method.
$req=preg_replace('/^'.preg_quote(self::$vars['BASE'],'/'). '\b(.+)/i','\1',rawurldecode($_SERVER['REQUEST_URI']));
This way you can reach your project under "domain/projectname/" and "server/PrOJeCtNamE/" and the rules will apply to both, no matter how base is written (case). In the Templates the BASE is getting replaced automatically by the correct BASE-var.
what you all think of it?
In 2.0.10, I can no longer set a value to a session, such as a user id.
To get it working again for now, I just commented out lines 893 & 894 of lib.php's exists method, e.g.:
static function exists($key) {
if (preg_match('/{{.+}}/',$key))
// Variable variable
$key=self::resolve($key);
if (!self::valid($key))
return FALSE;
$id=session_id();
$var=&self::ref($key,FALSE);
if (!$id && session_id()) {
// End the session
// session_unset(); // line 893
// session_destroy(); // line 894
}
return isset($var);
}
To demonstrate the issue:
1.) Make sure any old sessions are cleared:
F3::route('GET /clear',
function() {
echo 'session cleared';
F3::clear('SESSION');
}
);
2.) Try to set a session:
F3::route('GET /set',
function() {
echo 'This will try to set a user id session.';
F3::set('SESSION.user_id','JimmyJohns');
}
);
3.) Try to access the session value:
F3::route('GET /test',
function() {
if (F3::exists('SESSION.user_id'))
echo 'you have a user id session: '.F3::get('SESSION.user_id');
else
echo "you don't have a user id session";
echo '<br />';
if (F3::exists('SESSION'))
echo 'the general session variable is set';
else
echo "the general session variable is not set";
}
);
Using 2.0.10, the user id session value isn't available--either it can't be accessed or it was never successfully set. I think probably the latter. But by commenting out the two lines mentioned earlier, lib.php 893 & 894, then I can set and access the user id.
This works in 2.0.10 but causes an error in 2.0.11. It is a bit obscure but I've run across it in my project and it took me a while but now I know how you can recreate it. I've recreated this error in the latest git download.
On the most basic level here is how to recreate the bug.
edit the index.php to this:
<?php
require __DIR__.'/lib/base.php';
F3::set('DEBUG',1);
F3::set('UI','ui/');
F3::set('bug','this is a bug');
F3::route('GET /',
function() {
echo Template::serve('welcome.htm');
}
);
F3::run();
?>
Now create the ui/welcome.htm file like so:
welcome.htm file
{{@bug}}
<br>
<f3:include href="bug.htm"/>
Finally create the ui.bug.html file like so:
<br>
this is bug.htm
<br>
{{@bug}}
<br>
This line is not rendered.
Having any token in a template file (like {{@bug}} above) and the same token in a file included by the template throws an internal server error every time. The above example gives you:
Internal Server Error
Undefined variable: _bug
#0 C:/xampp/htdocs/f3bug/temp/localhost.tpl.1gu78sr:18 Template::serve('bug.htm','text/html',true,array(0=>'VERSION',1=>'bug'))
#1 C:/xampp/htdocs/f3bug/index.php:14 Template::serve('welcome.htm')
#2 C:/xampp/htdocs/f3bug/index.php:18 F3::run()
Take out the {{@bug}} token from either the welcome.htm file or the bug.htm file and you won't get the error. Also you don't get the error if you are using F3 version 2.0.10.
.
Hey,
I think in one of the earliest versions the system was just one file which felt really comfortable for me.
Any chance to get the system as one file?
with the new version 2.0.12 any route ending with / gets re routed. this adds some issues with ajax apps. please consider making it opt in
i have an app.. the url is for instance
my route is
$app->route('GET /ab', 'access; last_page; controllers\ab\controller_app_provisional->page');
it works ok (with the dont re route fix in 2.0.12) till i add ?apID=1 to the end then the route fails..
so i tried changing the routes to
http://adbooker.local/ab/ab?apID=1
$app->route('GET /ab/ab', 'access; last_page; controllers\ab\controller_app_provisional->page');
and it works fine
so seems to me that theres an issue with the routing engine if the "folder" is the first 1 and you add a ? it errors out
http://adbooker.local/ihateyoupage?apID=1 gives same results.. so its defs the first domain/?t=1 thats causing it
I try to handle a route like this:
F3::route('GET /','main.php; home.php');
But after main.php was executed, the chain breaks.
I tried giving a method first, this works, but also breaks with first .php.
F3::route('GET /','home; main.php; home.php');
---> executes home, executes main.php, break
F3::route('GET /','main.php; home; home.php');
---> executes main.php and break
I think the handling of external files (.php) is wrong. I found a return() there (method call()), I think that's what's breaking the chain.
When using F3::profile(), there is no data about executed SQL queries.
The problem is in exec function 3rd line: "$stats=&self::ref('STATS');"
Because STATS is a read-only value (it's in $readonly array), ref returns copy of this array. Please replace this line with something like "$stats=&self::$vars('STATS');" or add some functionality for checking direct execution of this static method (i'm talking about "ref").
This is from the old tracker. Wanted to re-post here so it isn't forgotten, since it's not in 2.0.10.
Problem:
F3's minification gets messed up when it encounters single or double quotes around a URL found in a CSS file. For instance, when using background images or @font-face declarations. Full description here on the original ticket:
http://sourceforge.net/tracker/?func=detail&aid=3511448&group_id=288268&atid=1220992
Solution:
Change web::minify line #71 to:
'/\b('"?<=url)((["'])*([^\1\r\n]+?)\1)/', // the line from 2.0.10 + fix
Just add an escaped single quote and a double quote before the first question mark. '"
First of all love the framework.
However I did some testing with the minimize option (Web::minify) and it works flawlessy with the css scripts. But when I add all my scripts to create one minimized url. The javascript is minified but the code stops working. Please let me know if you need more details and what kind of details so that I can supply them.
Regards,
Alex
F3::config incorrectly evaluates chained route handlers
e.g.
GET / = class::foo|class::bar|class::foo2|class::bar2
problem is on line 967.
Also seems, that true/false values are not evaluated properly in config files
e.g.
TEST = false
false is considered string, probably expected behaviour, but was evaluated as boolean false in 2.0.8
if there is no other autoloader registered, a call to class_exists($classname) will trigger an error if the class does not exists.
see https://github.com/KOTRET/fatfree/commit/bd63ce334ca8b5f6a3c7f580f6edbc1838661fb9
F3's code uses eval(). That's why I want to say: Avoid using eval, please...
If application root url is
/tff/
then according to documentation I should setup .htacces to:
RewriteBase /tff/ (not sure about end slash)
and my index.php should look like this:
F3::route('GET /tff/home', 'home');
function home() {
}
However, using /tff in home does not work at all. Instead, the only way I got it working was with
F3:route('GET /home', 'home');
with RewriteBase set to /tff/
The request url in the browser was in the form http://hostname/tff/home
The main clue for me was that once I took example file, changed its route from / to /subapp/ it broke.
I am using namecheap hosting provider for testing and that's the only way I got it to work.
When using base.php, I get lots of "undefined index" notices:
PHP Notice: Undefined index: DEBUG in \path\to\lib\base.php on line 1634
We were talking about the TAL Template Engine. They're doing automatically htmlentities() on template output which would be nice to have in F3 too. Optionally of course.
Any argues against this, except loss of render speed?
Benefits:
This is not a an issue but a suggestion. I think you should follow PSR-0 guidelines, it would make it easy to integrate with other libraries.
Cheers,
If you specify the LOGS variable with F3:set('LOGS', 'directory/') in order to setup a special path where log files get stored it is not really used.
Current code is (Log.php:77-78):
$this->filename=$this->ref('LOGS').$file;
$this->handle=fopen($file,'a+');
I think this should be:
$this->filename=$this->ref('LOGS').$file;
$this->handle=fopen($this->filename,'a+');
Hi!
How can i pass a string to the dict array?
I try to get it this way - but its doesnt work..
return array(
't_position_del' => 'Position {0, number} deleted!',
);
F3::get('t_position_del', array($id))
/foo?bar=hello%0Aworld
won't match
F3::request('GET /foo', 'foo');
While I definitely appreciate the many benefits of GitHub and I like being able to easily use Ctrl+F
to search the entire F3 site, I think the current setup is less than ideal.
Here are the options I can see which would improve upon it:
Ctrl+F
but doesn't skip content marked display: none;
.Commenting in the style of the PHP documentation could be restored using one of the following methods:
I'd be willing to try to implement one of these solutions for you if you're interested.
_
Example:
$sites = array(
'example.com' => true,
'test.eu' => false,
'example.org' => true,
'test.us' => true,
);
F3::set('sites', $sites);
var_export(F3::get('sites'));
Expectation:
array (
'example.com' => true,
'test.eu' => false,
'example.org' => true,
'test.us' => true,
)
Actual result:
array (
'example' =>
array (
'com' => true,
'org' => true,
),
'test' =>
array (
'eu' => false,
'us' => true,
),
)
.
Hi
One more for me, I am on a roll!
I have setup the following structure for my webserver www.example.com.
-.htaccess
-library
---fatfree
-app
---controllers
---views
---models
---etc
-public
---js
---css
---index.html
Now I want to redirect everything to public/index.php that is done by adding the following in the .htaccess
RewriteRule ^.htaccess$ - [F]
RewriteCond %{REQUEST_URI} =""
RewriteRule ^.*$ /public/index.php [NC,L]
RewriteCond %{REQUEST_URI} !^/public/.$
RewriteRule ^(.)$ /public/$1
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^.*$ - [NC,L]
RewriteRule ^public/.*$ /public/index.php [NC,L]
RewriteRule !.(php|js|ico|gif|jpg|png|css|htm|html|swf|txt)$ public/index.php
What the issue is, when my login form ( www.example.com/login) is filled correctly I want to redirect to the www.example.com.
I tried with the function F3:call(Controller->action) but then the url does not change so I went for the function F3:reroute('/'); Which basiscally takes me to the correct page. However it takes me to the page www.example.com/pubic/ which is not what I want I want it to go to www.example.com/
I noticed the that the reroute function uses the REQUEST['SCRIPT_NAME'] as the base for the url rerouting which is causing the issue.
Is there anyway I can fix this or do it otherwhise? I know I can do it by using F3:reroute('http://www.example.com'). But this does not seem correct to me. Also the public folder is prepended to all internal reroutes.
Thanks,
Alex
.
Route:
F3::route('GET /test', function () {
$error = new stdClass();
$error->id = 1;
$error->text = 'error text';
F3::set('error', $error);
echo Template::serve('test.phtml');
});
test.phtml:
<F3:check if="{{isset(@error)}}">
<F3:true>
<div>We have error</div>
</F3:true>
<F3:false>
<div>Everything is fine</div>
</F3:false>
</F3:check>
Browser outputs:
Internal Server Error
Fatal error: syntax error, unexpected '('
#0 C:/f3.local/temp/f3.local.tpl.0wdkdrz:1
f3.local.tpl.0wdkdrz
<?php if (isset(($_error=F3::get('error')))): ?>
<div>We have error</div>
<?php else: ?>
<div>Everything is fine</div>
<?php endif; ?>
in base.php the new CASELESS-Param is interpreted wrong.
Caseless = dont care about the case.
(self::$vars['CASELESS']?'':'i') should become (self::$vars['CASELESS']?'i':'') : if CASELESS then add modifier
Chris
Something similar Rack::MethodOverride would be fine:
http://rdoc.info/gems/rack/1.2.1/Rack/MethodOverride:call
trying to count records i noticed that the found-method adds an adhoc-field and calls find on the Axon. This looks legit but the problem is, that the find-method adds the *-Selector. This leads to unnecessary work for the SQL-Server as the result (x rows) is thrown away after that.
Hi,
This is more a question than an actual issue. When doing:
F3::route('GET /my_page','my_func',60);
How would you achieve the same in a config file? I did the following is this correct?
[routes]
GET /=my_page,my,my_func,3600
Thanks,
Alex
.
minify turns things like
tr:nth-child(odd) td
into
tr:nth-child(odd)td
which for example breaks bootstrap, unfortunately.
Really love the url() adjusting, though.
While juggling with FileDB and SQL, I was wondering why i cannot set a field value = 0 on Axon object.. everytime i saved it, the field becomes NULL in DB. It took me hours to figure out this little type comparison issue.
Bug Fix for that at:
ikkez@1e6fa61
Same thing in Jig, where i was not able to get a result where the condition contains a null field like
var_dump($JigObj->find(array('deleted'=>NULL)));
Bug Fix:
ikkez@d1f42c4
heil to the king
Usecase:
controller code
F3::set('GROUPS', $groups);
echo Template::serve('public_tpl/groups.html');
template snippets:
http://pastebin.com/7uuM6BzS
no F3 variable from GROUP cycle is available (or tokens not resolved?) in group.html template, although @group key and @Items in groups.html is populated ok.
Replace the (evil) "if" directive in the sample Nginx configuration with a simple try_files line:
try_files $uri /index.php;
While cross-browser testing, I noticed my background issues weren't showing up in IE8 (but did in all other browsers). After some testing I found the cause. In IE8 (maybe other versions of IE too, but I've only tested 8) background images do not load if there isn't a space after the closing parenthesis containing the URL and any text that follows it. Minify removes this space. I realize it's not ideal to add a fix for a certain browser, but IE8 is widely used unfortunately, so I think it's pretty critical or else minification of CSS prevents background images from loading in IE8.
/*Examples after minification. These are broken in IE 8 (images do not load)*/
background:url('/img/bg.png')no-repeat;
background:url('/img/bg.png')top right no-repeat;
/*these work in IE 8. Note the added space. */
background:url('/img/bg.png') no-repeat;
background:url('/img/bg.png') top right no-repeat;
.
I found that using a dynamic route handler for GET and a static one for POST causes a 405 method not allowed error.
I get a 405 when GET-ing /addImage
F3::route('GET /@action', 'Gallery->{{@PARAMS.action}}');
F3::route('POST /addImage', 'Gallery->addImage');
This fixes it & works for post & get
F3::route('GET /@action', 'Gallery->{{@PARAMS.action}}');
F3::route('GET /addImage', 'Gallery->addImage');
F3::route('POST /addImage', 'Gallery->addImage');
Shouldn't it work also in the 1st case, because the code worked before implementing the POST route?
In the F3::resolve function, we check if the "new" word is present in the output string. I guess this has something to do with object instantiation. This check procedure however has a side effect: dictionary strings containg the word "new" get enclosed in single quotes. E.g:
F3::set('_str1','an old man');
F3::set('_str2','in a new house');
echo F3::resolve('{{@_str1}} {{@_str2}}');
will output an old man 'in a new house'
Sorry to bring up minify again. In 2.0.12 minify no longer removes all comments. I think the pattern I'm seeing is that comments within braces are not being removed. I don't know whether that address all of them, but the following test can demonstrate it:
/* this works - this comment will be removed successfully */
.foo {
color: #000;
}
.bar {
color: #000; /* this doesn't work - this comment won't be removed */
}
.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.