Terablaze
Terablaze is a PHP MVC framework for developing web applications. It is an open source framework released under MIT License., (*1)
Installation, Configuration and Running
Requirements
- Web server
- PHP
- MySQL (optional)
- Composer
Installation.
1. Via Composer (recommended)
Navigate to the desired web-accessible folder on your server and run the following command from the command line., (*2)
composer create-project terablaze/terablaze ./
to install in the current folder or, (*3)
composer create-project terablaze/terablaze project-folder
to install in the 'project-folder', (*4)
Configuration
First, create a .env
file using the .ent.template
file as a guide, (*5)
Though the default Terablaze configuration settings is enough to get you started, it is advisable and in some cases compulsory to go through the config
directory and configure accordingly., (*6)
Running
Navigate to your project's root folder via the command line and run, (*7)
php -S localhost:8000
visit http://localhost:8000
in your browser., (*8)
If you are not using the build in PHP server, visit your installation folder in your browser through your server (could be a live domain, remote ip or localhost if you are running on a local machine)., (*9)
If you see the Terablaze welcome page without errors, then your installation is successful., (*10)
The controller to the welcome page is src/App/Controller/WelcomeController.php
and the view file is src/App/views/welcome.php
, (*11)
Using
Controllers
Create your controllers in the src/App/Controller
folder (You can use any directory as long as the Controller namespace/class matches the directory/file path)., (*12)
Your controller class should extend the base controller \Terablaze\Controller\Controller
to have access to some nice features the base controller offers, (*13)
Models
Create your models in the src/App/Model
folder (You can use any directory as long as the Model namespace/class matches the directory/file path)., (*14)
Your model class should extend the base model\Terablaze\Ripana\ORM\Model
, (*15)
Views
Create your views in the src/App/views
folder., (*16)
To load your view files, simply use, (*17)
$viewContent = $this->renderView('App::view_file_with_or_without_extension')
or
return $this->render('App::view_file_with_or_without_extension');
to return a response instance with loaded view as content body, (*18)
Pass an optional second argument which is an array and is extracted internally and therefore available in the view as variables., (*19)
For instance:, (*20)
$data = [
'name' = 'Terablaze',
'type' = 'MVC Framework',
'language' = 'PHP'
];
$this->renderView('App::home', $data);
The code above will make the variables $name
, $type
and $language
available in the src/App/views/home.php
view file, (*21)
To load a view from within another view, use $this->includeView('App::included_view_file')
, this allows the included view have access to the variables extracted in the parent view, (*22)
Stability status
It is very important to note that this framework is currently very unstable and may change frequently for now.
As much as we use it in several live projects(from really simple projects to very
big and complex projects), we do not advise you to use in a production environment
unless you are sure of what you're doing and you're willing to invest the time., (*23)
Contributing
Simply fork the project and make pull requests. Try to go through the code to not deviate too much from our code style., (*24)
If you are interested in joining the development team, simply mail tomiwa@teraboxx.com
, (*25)
Note that the email used here will likely change soon., (*26)