PHP code example of hkulekci / basicmvc

1. Go to this page and download the library: Download hkulekci/basicmvc library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

hkulekci / basicmvc example snippets


 
/************** Some Configurations ****************/
define("APP_DIR", __DIR__ . "/app/");
define("APP_THEME", "default");
define("APP_TEMPLATE", APP_DIR . "public/view/theme/".APP_THEME."/");
/********** End of Some Configurations *************/


,
        'templates.path'    => APP_TEMPLATE
        )
    );

$basicmvc = new BasicMVC($app, array(
    "controllers_path"   => APP_DIR . "public/controller/",
    "models_path"        => APP_DIR . "public/model/",
    "library_path"       => APP_DIR . "public/system/library/",
    "template_constants" => array(
        "APP_THEME"     => APP_THEME
    )
));

$app->map('/(:directory(/:controller(/:method(/:args+))))', 
            function (
                $directory = "home", 
                $controller = "home", 
                $method = "index", 
                $args = array()
            ) use($app, $basicmvc) {

    $route = array(
        "directory"       => $directory,
        "controller"      => $controller,
        "method"          => $method,
        );

    echo $basicmvc->run($route, $args);

})->via('GET', 'POST', 'PUT', 'DELETE');

$app->run();

    app/
        public/
            controller/
                ...
            model/
                ...
            view/
                ...
    .htaccess
    index.php