Mudrock Framework
Discover all the features:
Table of Contents
Requirements
Installation
- Install by Composer:
composer create-project mudrock/mudrock my-project
- Run by Docker:
cd my-project
docker-compose build
docker-compose up
- Now open your browser and access the URL:
https://localhost:8000
Routes
Allowed request types:
- GET
- POST
How to define routes:
- All routes must be defined in the file:
app/config/routes.php
- You can declare the route using a method of some Controller:
$this->get('/MyRoute', 'MyController@MyFunction');
- Or simply define a callback:
$this->get('/MyRoute', function(){
return "This is my callback when accessing this route";
});
Translations:
- First, you need to create a folder named after the desired language. For example, we will use the language "Portuguese". So, we create the folder as desired:
app/languages/portuguese/
- Now we need to create the files with the translations. We recommend creating a file for each Controller:
app/languages/portuguese/MyController.php
- In the created file ("MyController.php"), we will have a structure similar to this:
return [
'my_phrase' => 'My sentence translated to the desired language'
];
- Now we need to load this translation file into the "construct" method of the Controller file:
namespace app\controllers;
use system\core\Controller;
class Welcome extends Controller {
public function __construct() {
$this->load_language('MyController');
}
}
?>
- Once that's done, we can now use our translation in the Controller and also in the View we are using:
$this->lang('my_phrase');