elementphp / element
Lightweight PHP Framework
This package is auto-updated.
Last update: 2024-05-11 14:32:10 UTC
README
MVC Framework for PHP
What is it?
A lightweight MVC framework for PHP that can be easily deployed and updated within any hosting.
Getting Started
Prerequisites
- Apache webserver (must have mod_rewrite enabled)
- PHP V7+ (probably works on lower versions, but untested).
GitHub
Clone or download repository.
Composer
-
If you haven't already done so, install Composer
-
Create a directory in your webspace to contain your files
-
Create a file named composer.json. See example below (name is optional and can be changed)
-
Open command prompt or terminal, cd to directory and input the following command (without quotes)
i. Windows: 'composer install'
ii. Linux/Mac: 'php composer.phar install'
{ "name" : "element", "require": { "elementphp/element": "dev-master" }, "minimum-stability": "dev", "prefer-stable": true }
Quick Start
Navigate to app > configuration > configuration.php and update host and root in the domain section of the $config array.
E.g On localhost in a subdirectory named element ...
host = 'localhost'
root = 'element'
"domain" =>[ "host" => "localhost/", "root" => "element" ],
Documentation
Full documentation can be found here
Model
(Example.php)
<?php namespace element\mvc; class Example extends Model { public $id; public $message; }
View
(index.tpl)
<!DOCTYPE html> <html> <head> <title>View Example</title> </head> <body> <p>{$message}</p> </body> </html>
Controller
(IndexController.php)
<?php namespace element\mvc; class IndexController extends Controller { public function indexAction() { /* If id is AI primary key we shouldn't explicitly set it. */ // create and save model $model = new Example(); $model->message = "Hi there!"; $model->save(true); // retrieve model // kind of redundant, because we have it in $model, just to explain! :) $example = Example::getById($model->id); // pass our message to view $this->view->assign('message', $example->message); } }
Versioning
The versioning scheme we use is SemVer.
Built with
Authors
Paul Lawton - Creator
Contributing
Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to us.
Licence
Open Source under BSD 3 Licence