Download the PHP package php-mohamed-nabil/marrow-framework without Composer
On this page you can find all versions of the php package php-mohamed-nabil/marrow-framework. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download php-mohamed-nabil/marrow-framework
More information about php-mohamed-nabil/marrow-framework
Files in php-mohamed-nabil/marrow-framework
Package marrow-framework
Short Description marrow is a php MVC Framwork for building php web application with a good mvc pattern structure makes development more easier
License
Informations about the package marrow-framework
Marrow MVC architecture
A php framework Using MVC design pattern build from zero with features like (command line micros,routes,template engine,containers,service provider pattern, mysql db,middlewares), help ypu understand poupler frameworks and how it works and operating from inside. get started with new project:
see the below repo to create new skeleton project. https://github.com/PHPMohamedNabil/marrow
This the first version and it is under testing
Table of contents
- Installation
- Request Lifecycle
- Kernal File
- Kernal-from-inside
- Routes
- Style-template-engine
- Middlewares
- Controllers
- Models&Database
- creating-migration-file
- Licence
installation
Request-lifecycle
all request to web applications directed to public/index.php file that acts as a front controller for all web application requests
First thing is creating a application new instance and then run required classes or servicess (startups under startups folders) using kernal class to handel application request and then retrun response to the client.
kernal-file
kernal file it is like a motherboard that conducts,configuraing and preparing all application settings and runs app services : check kenral file core/http/kernal.php:
lightes-component
This class implements design pattern you can choose or implement all services runs when application requests starts and run services after response returned: check core/lightes:
Applying on facade pattern
use lightes interface for creating your own facede class implementation :
Kernal-from-inside
see kernal handel function takes two parameters first is request object and seconde is application instance:
runs middlewares before and afer application requests and then routes the request to the resource:
kernal light on and light off methods:
you can see this methods runs every thing before request and after response outputed:
migration-commands
to install db scheme run: run all migrations create new migration file in migration folder rollback all migrations rollback migration_name file
controllers and models commands
create new controller file under controllers folder
create new resource controller under controllers folder
create new resource controller and model file under controllers folder and model folder
create new controller and model file under controllers folder and model folder
create new model file under models folder
create new respository file under respositories folder
env file
you can browse .env file to check and configure database connection and web app settings and session settings:
feal free to edit the above setting to your enviroment settings.
generate app secret key
this secert key important as it is important in hashing data algorithim it is hashes application name and uses it hashing process as secret key.
run command php generate_key
you will see key generated take it and copy it in as a value of SECERET_KEY in .env file
Routes
Supporting GET,POST,HEAD,PUT,DELETE,OPTIONS
routes located in app\routes folder: 1-web.php for web routes
in our project we working on routes you can change it as you want:
routes placeholders
create route placeholders just but : before the placholder:
routes regx route
make regex routes with method regx just write your own regular expressions (without regx delemeters):
App routes list
run command php route_list to see app routes
Style-template-engine
marrow uses style template engine it is an fast and powerfull php template engine built from native code with strong featues like (template inheritance,template sections and hard compile feature) see style documentation here :style
App url
your will go to app\config\config_constants.php file : you will see all application constatnt the most imporatant part is SITE_URL
change SUTE_URL constant to your website or localhost url that has a document root in to public folder.
_tcsrf
this a csrf token parameter you have to send it along with any post request (check cookies to get the full csrf token ) see like that:
Middlewares
create application general middlwares or routes middlewares from config/middlewares.php and disable remove csrf middleware from middlewares array.
Service-providers
create application service provider (classess and servicess runs before application bootstraped). this classes you can create under startup folder and assign it to startups array in app\config\startup.php.
Applying on Container Pattern (Inversion of control)
go to startup folder and create new file example : TimeZoneStartup.php for setting default timezone before app startsup (before every request to application) like service providers in laravel framwork
This means that every request to application will set date_default_timezone_set to 'Europe/Moscow' or you can write your other method to change timzone like date_default_timezone_set() builtin php function.
all startups are run one by one instantiating every class and run (boot) startup method then run register method
Controllers
acting like controller system in laravel (emulate most) you can assign middleware at constructor function:
Models-Database
just create models like any framworks but it is uses native db (no ORM libaraies here).
connecting to database like this :
all models returns object of model data
or like this :
NativeDB-class
you can create custom queries easy and fast using this class :
creating-migration-file
First run command php create_migration users_table (replace users_table by your migration file name ). it will create a new file users_table_date_time_000 under migration folder
after making migration file with sql scheme run php migrate iw will run all migration files and commit it all. to rollback your migration run php migrate rollback your migration run php migrate roll=users__2023_09_03_17_56_59 for rollback all migration run php migrate roll=all
Exceptions:
has a special custom style using ignition libarary
The concept of large framworks (middlewares,pipeline,repositories,commands,migrations,containers,configs,template-engine)
finally run php marrow to start your project on localhost:8000 or ex: run php marrow (port number) php marrow 4500
All versions of marrow-framework with dependencies
respect/validation Version ^2.2
intervention/image Version ^2.7
nesbot/carbon Version ^2.67
rakit/validation Version dev-master
league/pipeline Version dev-master
optimus/onion Version ~1.0
vlucas/phpdotenv Version 5.6-dev
verot/class.upload.php Version dev-master
doctrine/inflector Version 2.0.x-dev
symfony/password-hasher Version 5.4.x-dev
php-mohamed-nabil/style Version dev-master
filp/whoops Version ^2.15
league/booboo Version dev-main
spatie/ignition Version ^1.9
httpsoft/http-server-request Version dev-master
league/oauth2-facebook Version dev-main