duxtec / modulephp
A modular framework for PHP
Installs: 3
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 1
Type:project
Requires
- php: ^7.2 || ^8.0
- ext-mbstring: *
- ext-openssl: *
- monolog/monolog: 2.8
- nesbot/carbon: ^2.59
- phpmailer/phpmailer: ^6.4
- psr/log: 1.1.4
- respect/validation: ^2.2
Requires (Dev)
- fakerphp/faker: ^1.19
- mockery/mockery: ^1.4.2
This package is auto-updated.
Last update: 2024-03-30 00:26:39 UTC
README
About
ModulePHP is a modular PHP framework for multiple userlevels.
Why use ModulePHP?
-
Automatic construction of routes for pages, assets and controllers.
-
Userlevels encapsulation.
-
Built-in login system.
-
Layout building tool.
-
HTML renderer.
Installation
-
Download ModulePHP and extract it to your preferred folder.
-
Open the extracted folder.
-
Run
php scripts/install
or fill in the
config/*.env
files manually.
-
Run
php scripts/localhost
to start a local instance.
-
Run
php scripts/create_userlevel
to add new userlevels.
Front-end
-
Open the
app/{userlevel}
folder for the wanted userlevel.
-
Edit the files
app/{userlevel}/view/base/head/favicon.php
app/{userlevel}/view/base/head/metatag.php
app/{userlevel}/view/base/head/script.php
app/{userlevel}/view/base/head/style.php
app/{userlevel}/view/base/body/header.php
app/{userlevel}/view/base/body/aside.php
app/{userlevel}/view/base/body/main.php
app/{userlevel}/view/base/body/footer.php
to build the standard structures for that userlevel.
-
Structures can be made in pure HTML or using special classes in the base namespace, as in the examples.
-
This classes must have the correct name and contain a
render()
method that returns the structure as a string.
-
-
Create files in the
app/{userlevel}/view/pages
folder where the routes are built automatically with the same name as the file. The route will be
domain.com/name
. -
Add the necessary assets in the
public/assets
folder, but CAUTION, everything in the assets folder is publicly and globally accessible. The route will be
domain.com/assets/name
. -
The
app/{userlevel}/view/modules
folder can be used to create frequently used HTML blocks and segment development, similar to React components. To import a module use the static method
MVC::Module(name)
;
Back-end
-
Open the
app/{userlevel}
folder for the desired userlevel.
-
Create files in the
app/{userlevel}/model
folder and insert the objects that will be used by the controllers. To import a model use the static method
MVC::Model(name)
. -
Create files in the
app/{userlevel}/controller
folder that the routes are built automatically with the same name as the file. The route will be
domain.com/controller/name
.
Useful tips
-
Access the user id and level by the USERID and USERLEVEL constants, respectively.
-
The
global
userlevel holds features that must be offered globally for logged in and out users. If a file with the same name exists at the user level, that file replaces the global file.