I am trying to use the php fat free framework (aka F3), to quickly build a web application.
In theory (from reading the documentation), it should be a doddle (i.e. easy), however, I have been stuck on a single problem for days, and judging from similar questions here on stackoverflow, it seems I'm not the only one struggling with this issue.
Here are the salient facts:
- I am using wamp server to run F3.
- My F3 project resides under /location-to-wamp-folder/www/fatfree-master
- I have setup a virtual host for Apache under wamp, so http://fatfree-master runs index.php
This is where the trouble begins. When I navigate to http/fatfree-master, I get the error which is the title of this question; namely:
Not Found
HTTP 404 (GET /) C:/wamp/www/fatfree-master/index.php:111 Base->run()
My index.php looks like this:
<?php // <- surprisingly, I had to add this line to the index.php example provided by F3, was this an oversight or a deliberate design feature?
$f3=require('lib/base.php');
$f3->set('DEBUG',3);
$f3->set('UI','ui/');
....
// custom PHP code defining routes etc ...
....
$f3->run(); // barfs here
Now, I would be the first to admit, that I do not understand the arcane syntax of Apache rewrites, so I have left my .htaccess file as it was (when I downloaded F3).
Here are the contents of my .htaccess (the default file provided by F3):
# Enable rewrite engine and route requests to framework
RewriteEngine On
# Some servers require you to specify the `RewriteBase` directive
# In such cases, it should be the path (relative to the document root)
# containing this .htaccess file
#
# RewriteBase /
RewriteRule ^(tmp)\/|\.ini$ - [R=404]
RewriteCond %{REQUEST_FILENAME} !-l
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php [L,QSA]
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization},L]
Can anyone explain to me, why I am getting the 404 error, and also how to fix it?
[[Additional Notes]]
I have two routes in my (edited) index.php file. My index.php looks like this now:
<?php
$f3=require('lib/base.php');
$f3->set('AUTOLOAD','app/controllers/');
$f3->set('DEBUG',3);
$f3->set('UI','ui/');
/* Tools */
$f3->route('GET @tools_calculator_dates: /tools/calculator/dates', 'Beer->list');
// Default route
$f3->route('GET /',
function() {
echo 'Hello, world!';
}
);
$f3->run();
When I access / in my browser, I get "Hello, world!" (as expected) When I access /tools/calculator/dates in the browser, I get the following error:
Not Found
HTTP 404 (GET /tools/calculator/dates)
• C:/wamp/www/fatfree-master/index.php:119 Base->run()
Now, I have a class here: /path/to/wamp/www/fatfree-master/app/controllers/beer.php
The contents of the class are:
<?php_
class Beer
{
function list() {
echo "Beer::list() called!";
}
}
Why I am getting the 404 error?.