This is a simple PHP MVC framework (inspired by Symfony). I chose to write my own one because I find Symfony oversized/overpowered and Doctrine didn't give the results I wanted
- installation
- configuration
- configurator
- note regarding AJAX
- documentation
- tests
- changelog
- next steps
- URL rewriting
- form builder
- dependencies
- credits
- Clone or download the project
- Put it in the appropriate web server folder (in my case, Apache's "
htdocs")
The configuration consists in JSON files located in the "/cfg" folder. It already contains database info & routes; don't forget to customize these 2 files
Extra configuration can be added in additional JSON files (I recommend 1 per settings type). Any non-JSON file will result in an error
This class reads the configuration files, then makes the content available through a public array used as a dictionary
There's no need to modify this as you add configuration files
Note
This framework uses AJAX calls for every user action, e.g. form submission or showing pages and data
You'll probably need to get some entities ("data classes" (as it's called in Kotlin) living in the "/model" folder) back as JSON. In that case, make them serializable by implementing the JsonSerializable interface:
- declare the class implements the
JsonSerializableinterface - add this method:
public function jsonSerialize (): object { return ((object) get_object_vars ($this)); }
The code documentation is written in Doxygen format. I chose this one as it is widely used
I encourage you to extend this by documenting your controllers and views
Unit tests will be performed with PHPUnit against controllers and model. Functional ones will be performed with Robot Framework against views
This is the initial version (1.0.0). The changelog is currently empty
Note
The how-to will apply to Apache. Other web servers may do this differently
In a URL readability and security purpose, I will remove useless URL parts such as "index.php?route="
In order to save time and work, this will recursively convert an entity into an equivalent HTML form. It can't be too generic, so it will use a configuration, mainly including excluded and optional fields
I use the following components to write this framework:
- PHP 8.1.9
- jQuery 3.7.0
- SweetAlert2 11.10.3
- Apache 2.4
- Xdebug 3.1.5
- PHPUnit 10.5
I asked ChatGPT to write a sample MVC structure & route system (router only). Then I customized the result