Basic expense tracking software. This is my first project using the Fat-Free Framework.
It uses the Fat Free Framework, a lightweight PHP framework, and follows the example in Fat-Free CRUD with MVC
It also makes use of the following components:
- sorttable: HTML5/Javascript table with sorting capabilities. It is quite handy when working with data.
- phpGraph: SVG charts from PHP data
- PhpSpreadsheet: For importing XLSX files.
- parsecsv-for-php: For importing csv files.
- pdfparser: For importing PDF files.
The code is structured as follows:
- app : Actual application code. Follows an MVC arrangement.
- classes : Misc classes that are autoloaded by the Framework.
- Fm : Form shortcuts
- phpGraph : PHP SVG graph class
- Sc : Misc. Shorcuts (to use in view templates and reduce typing)
- models : Data Access Objects.
- controllers : Main classes that do stuff. Some classes worth mentioning:
- AppMain : Main window (shows the welcome dashboard)
- BackupController : Handles backups and restores
- ImportController : Manages bulk imports
- RptSummary : Generate year summary reports
- views : Mostly PHP templates as HTML with embedded codes. But also JavaScript is in there.
- classes : Misc classes that are autoloaded by the Framework.
- config : FatFree configuration files.
- data : contains data that will be editable from the web interface.
- rules.php : Used to assign categories to posting date.
- triggers.php : Used to generate postings automatically (i.e. to balance accounts)
- Importers/ : Contains classes used when importing bank data
- lib : symlink to PHP libraries
- scripts : utility scripts for bootstraping and maintenance
- init.sql : Use
php index.php /restore scripts/init.sql
to initialize the MySQL database. - newtest :
./scripts/newtest ../NeuSol ../NeuDev
to copy production to test. - secfg : Apply
selinux
contexts and UNIX permissions. - upgrade.sql : Upgrade schema.
- init.sql : Use
- submodules : where all the git modules are registered.
- ui : static files that used for rendering the user interface.
- Web Server (Tested on Apache 2.4.52)
- PHP (Tested on 7.4.26)
- MariaDB (Tested on 10.3.32)
The web server must have mod_rewrite
enabled and allow .htaccess
overrides.
- Create a directory in your web server, e.g.
NeuSol
. The nameNeuDev
is special for a test instance. In that case thenonprod-config.ini
is also read and needs to be configured. - git clone --recursive https://github.com/iliu-net/NeuSol.git NeuSol
- If on a SELINUX system you may need to run:
- scripts/secfg
- Create a database and a database user
- create database pfm;
- GRANT ALL PRIVILEGES ON pfm.* TO 'pfm'@'localhost' IDENTIFIED BY 'mypass';
- Configure this in config/config.ini
- Initialize the database schema:
- php index.php /orestore scripts/init.sql
- Point your web-browser to your app directory.
- More in-depth business rules can be created in:
- data/rules.php
- data/triggers.php
- Custom importers can be added in:
- data/Importers/*.php
- Balance is the amount at the end of the day.
OK, so this is my first try at an FatFree MVC web application. So somethings I learned:
- We need to dwelve better into FatFree's autoloading capabilities and how namespaces are handled.
- In
routes.ini
we declareroute => {controller}->{method}
, I think it would be cleaner if we had:route => {controller}->view
, and then in theview
function we declare:function view($f3,$params)
. Well,$params[0]
has the route itself, which actually should refer to aview
in theview
folder. - The models are actually
DAO
. We should name these accordingly with a DAO suffix. (This has to do with the fact that we are using a flat namespace) - There ought to be a good way to abstract how reports are done. We are not there yet.
- When FatFree makes the Hive available in templates as variables, these variables are
already escaped. If you want to use the raw variables (unscaped) you should use the
$f3->get
method to read the Hive directly.