Green Neon Design

Base Web Application

I've been working some projects recently and found that I was copying and pasting snippets from previous projects improving them and then when I returned to other projects, well things weren't working right because I didn't backport those improvements. Basically I was being a smart programmer reusing code but doing a bad job of it. Finally, last summer, I got to the point where I had to put a stop to the bad and be better at my work. Thus the Base Web Application was born.

Base Web Application is a PHP project that has a URL to code module dispatcher (called Application) along with a simple API mode, database session storage, and some other goodies. In order to create a web application from this, I fork it as a new project and add this Base Web Application repository as “upstream”. Next, I add one or more “modules”. When I am satisfied, I commit to the forked repo and deployment is often as simple as ssh'ing to the web host and performing a git pull origin master.

Requirements

Base Web Application aims to be incredibly flexible as far as server and database software. Other configurations may be possible (e.g. NGINX) but out of the box it requires:

I use Apache 2.4 with PHP 7.1 via mod_php and MariaDB 10.2.14 on my trusty old laptop. My preferred web host offers Apache 2.4, PHP 7.2 via FastCGI and MySQL 5.5.

Getting Started

Fork this project using git or the BitBucket web interface and then clone to your development machine. Ready a webserver by enabling mod_rewrite and mod_php in apache and an appropriate pdo driver loaded in php. Use either the command line interface or a graphical tool like Postico or Sequel Pro to create a new database and then run the sql stored in the “Database/schema” folder for for DB engine of choice. Next copy Site/config/config-sample.json to Site/config/config.json and edit this config.json to configure the appropriate connection parameters. Finally point the ${DocumentRoot} of your webserver to the Site folder in the project.

There is one premade module, Simple User Module, and one theme, Material, currently available for quick integration into our project as git submodules. Additionally, the old Extras repository is being rebuilt as an Example project you can try for yourself... I work on this as needed for a paying client or in my spare time so your understanding is appreciated.

Many modules assume that you have FontAwesome installed into ${ProjectRoot}/Site/components/font-awesome. You can add Font Awesome as a submodule just as you would add a theme or module.

Development

Modules include at a minimum a “View Controller” whose methods become URLs. The view controller must be implemented in a file named “ViewController.php”, derive from “\ViewController” and be namespaced in a namespace that is named the same as the enclosing folder. Modules typically also have one or more models and some number of views which are fragments of HTML/PHP that are wrapped in the theme. It is generally the View Controller's responsibility to import the files implementing any models it needs. The provided User module is a notable exception as it's model is imported during Application startup. The “Shape” example is a better starting point than the provided User module for those just getting started.

Support

There is no support for those using this software. Nor will feature requests necessarily be acted upon. If you wish to engage me professionally for the purposes of creating a derivative project, implementing a feature or teaching your team to use this framework; please contact me through my business website: tomegan.tech

License

MIT License

Copyright (c) 2018 Thomas K Egan <tkegan@greenneondesign.com>

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Source Code