A PHP-based user-authenticated Saas boilerplate by aoWare, using:
- Slim 4 Framework
- Twig 3 Template Engine
- Slim-Psr7 as PSR-7 implementation
- PHP-DI as dependency injection container
- Play bootstrap template
- Tabler bootstrap template
- https://github.com/konsav/email-templates email template
- nextras/dbal as a light database abstraction layer
- TODO: JWT Authentication / PHP-JWT
- Alertify pretty browser dialogs and notifications
- Switchery iOs 7 Switches
- Web server with URL rewriting
- Composer
- PHP 8.1 or newer.
- MySQL/MariaDB.
- Composer
git clone https://github.com/aoware/slim-saas-boilerplate.git
clone git repocd slim-saas-boilerplate
change working directory to root project foldercomposer install
install dependenciescp config.dist config.php
creates a new config file for you- Edit config.php with MySQL configurations and more
- Execute
db_source/migrations/initial_db.sql
run initial database migration
- set virtual host to project public folder
- Only use snake case for variables, classes, namespace (everything really)
- Configuration parameters should be stored in
/config.dist
and/config.php
. Those should have a prefix ofCONF_
to clearly identify them in the source code - Do not use abbreviations in variables or classes definition.
$ac_in
could be read as$account_inported
or$actual_invoice
. - Do not use include or require. All classes should be autoloaded or in a container
- Do not use
use
. All objects should be defined with their full qualified namespace path. - DB queries must use prepare statements. 2 methods:
- use generated models that provided methods for each indexes existing on a table.
- use DBAL nextras/dbal Database Abstraction Layer
- DB object create statements to be stored in folder
/db_source
in the appropriate object type - All controllers should return a valid PSR 7 response (html, json, download/stream or redirection).
echo $something;die();
is not permitted. - $_SESSION variable should only use a single entry
login_token
, which sole purpose is to validate the user logged in against thelogin_token
column in theusers
table
- Only use snake case for tables, columns, functions and procedures names
- Do not use abbreviations in variables or classes definition.
- Column names should not repeat the name of the table. For example
client_rep_name
should bename
in tableclient_rep
. - First column of all tables must be set as
id int(11) NOT NULL AUTO_INCREMENT
- All tables to have a comment
- Columns with ambiguous name should have a comment
- Column that reference a foreign key should be set as "table_name_in_singular"_id int(11) NOT NULL
- Index should be named as 'IDX_' + table name + column(s) name, where table name and columns name are in snake_case