Skip to content

Mudrock-Framework/Mudrock

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

72 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Mudrock Framework

GitHub go.mod Go version of a Go module     License     PHP Version Require


💡 Mudrock is a MVC PHP framework, which was inspired by the Laravel and CodeIgniter frameworks.
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 up


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:

With the translations feature it is possible to have multiple languages in your project. All this simply quickly!

  • 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:
<?php

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:
<?php
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');